-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathCMakeLists.txt
107 lines (91 loc) · 3.04 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
cmake_minimum_required(VERSION 3.5)
project(class_loader)
# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
set(CLASS_LOADER_IGNORE_AMENT FALSE CACHE BOOL
"Do not use ament when building this package.")
if(NOT CLASS_LOADER_IGNORE_AMENT)
find_package(ament_cmake)
find_package(ament_cmake_ros REQUIRED)
set(explicit_library_type "")
else()
set(explicit_library_type "SHARED")
endif()
find_package(console_bridge_vendor REQUIRED) # Provides console_bridge 0.4.0 on platforms without it.
find_package(console_bridge REQUIRED)
find_package(rcpputils REQUIRED)
if(ament_cmake_FOUND)
ament_export_dependencies(console_bridge)
ament_export_dependencies(rcpputils)
endif()
add_library(${PROJECT_NAME} ${explicit_library_type}
src/class_loader.cpp
src/class_loader_core.cpp
src/meta_object.cpp
src/multi_library_class_loader.cpp
)
target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
if(ament_cmake_FOUND)
target_link_libraries(${PROJECT_NAME} PUBLIC
console_bridge::console_bridge
rcpputils::rcpputils)
ament_export_targets(${PROJECT_NAME})
else()
target_include_directories(${PROJECT_NAME}
PUBLIC ${console_bridge_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${console_bridge_LIBRARIES})
endif()
if(WIN32)
# Causes the visibility macros to use dllexport rather than dllimport
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(${PROJECT_NAME} PRIVATE "CLASS_LOADER_BUILDING_DLL")
endif()
if(BUILD_TESTING)
find_package(ament_lint_auto QUIET)
if(ament_lint_auto_FOUND)
# TODO(mikaelarguedas) add copyright test once the linter accepts /** block comments
list(APPEND AMENT_LINT_AUTO_EXCLUDE
ament_cmake_copyright
)
ament_lint_auto_find_test_dependencies()
# Files in test/fviz_case_study do have compatible copyrights
find_package(ament_cmake_copyright)
ament_copyright(
TESTNAME copyright_check_tests_only
"test/fviz_case_study"
)
endif()
add_subdirectory(test)
endif()
if(ament_cmake_FOUND)
ament_package(
CONFIG_EXTRAS "class_loader-extras.cmake"
)
else()
set(TARGET_NAME ${PROJECT_NAME})
set(PKGCONFIG_LIBS
${console_bridge_LIBRARIES}
)
# Prepare and install necessary files to support finding of the library
# using pkg-config
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/src/${PROJECT_NAME}.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
@ONLY)
install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc" DESTINATION lib/pkgconfig)
endif()
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
install(DIRECTORY cmake
DESTINATION share/${PROJECT_NAME})
install(DIRECTORY include/ DESTINATION include/${PROJECT_NAME})