Skip to content

Commit 1a02c73

Browse files
authored
add missing export of stdc++fs and TinyXML2 via modern CMake (#189)
Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
1 parent 584f7bf commit 1a02c73

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

pluginlib/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,28 @@ ament_export_dependencies(ament_index_cpp class_loader rcutils rcpputils tinyxml
2727
ament_export_include_directories(include)
2828
ament_export_targets(${PROJECT_NAME})
2929

30+
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_FLAGS MATCHES "-stdlib=libc\\+\\+")
31+
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
32+
# Before LLVM 7.0, filesystem is part of experimental
33+
set(FILESYSTEM_LIB c++experimental)
34+
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
35+
# Before LLVM 9.0 you have to manually link the fs library
36+
set(FILESYSTEM_LIB c++fs)
37+
else()
38+
# Starting at LLVM 9.0 filesystem is built in
39+
set(FILESYSTEM_LIB)
40+
endif()
41+
else()
42+
set(FILESYSTEM_LIB stdc++fs)
43+
endif()
44+
45+
if(UNIX AND NOT APPLE)
46+
# this is needed to use the experimental/filesystem on Linux, but cannot be passed with
47+
# ament_export_libraries() because it is not absolute and cannot be found with find_library
48+
target_link_libraries(${PROJECT_NAME}
49+
INTERFACE ${FILESYSTEM_LIB})
50+
endif()
51+
3052
install(
3153
TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
3254
)

pluginlib/pluginlib-extras.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,10 @@ endif()
4444
find_package(tinyxml2_vendor REQUIRED)
4545
find_package(TinyXML2 REQUIRED)
4646
list(APPEND pluginlib_LIBRARIES ${TinyXML2_LIBRARIES})
47+
48+
add_library(tinyxml2_vendor INTERFACE)
49+
target_include_directories(tinyxml2_vendor INTERFACE
50+
${TinyXML2_INCLUDE_DIRS})
51+
target_link_libraries(tinyxml2_vendor INTERFACE
52+
${TinyXML2_LIBRARIES})
53+
list(APPEND pluginlib_TARGETS tinyxml2_vendor)

0 commit comments

Comments
 (0)