-
Notifications
You must be signed in to change notification settings - Fork 101
/
Copy pathCMakeLists.txt
100 lines (83 loc) · 3.22 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
cmake_minimum_required(VERSION 3.5)
project(pluginlib)
# 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()
find_package(ament_cmake REQUIRED)
find_package(ament_index_cpp REQUIRED)
find_package(class_loader REQUIRED)
find_package(rcutils REQUIRED)
find_package(rcpputils REQUIRED)
find_package(tinyxml2_vendor REQUIRED)
find_package(TinyXML2 REQUIRED) # provided by tinyxml2 upstream, or tinyxml2_vendor
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
target_link_libraries(${PROJECT_NAME} INTERFACE
ament_index_cpp::ament_index_cpp
class_loader::class_loader
rcutils::rcutils
rcpputils::rcpputils
tinyxml2::tinyxml2)
ament_export_dependencies(ament_index_cpp class_loader rcutils rcpputils tinyxml2_vendor TinyXML2)
ament_export_targets(export_${PROJECT_NAME})
install(
TARGETS ${PROJECT_NAME} EXPORT export_${PROJECT_NAME}
)
install(
DIRECTORY cmake
DESTINATION share/${PROJECT_NAME}
)
install(DIRECTORY include/ DESTINATION include/${PROJECT_NAME})
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
find_package(ament_cmake_gtest REQUIRED)
add_library(test_plugins SHARED ./test/test_plugins.cpp)
target_compile_definitions(test_plugins PRIVATE "TEST_PLUGINLIB_FIXTURE_BUILDING_LIBRARY")
target_include_directories(test_plugins PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test/include>")
target_link_libraries(test_plugins ${PROJECT_NAME})
include("cmake/pluginlib_enable_plugin_testing.cmake")
pluginlib_enable_plugin_testing(
CMAKE_TARGET_VAR mock_install_target
AMENT_PREFIX_PATH_VAR mock_install_path
PACKAGE_NAME "test_pluginlib"
PACKAGE_XML "test/test_package.xml"
PLUGIN_CATEGORY "test_pluginlib"
PLUGIN_DESCRIPTIONS "test/test_plugins.xml"
PLUGIN_LIBRARIES test_plugins
)
ament_add_gtest(${PROJECT_NAME}_unique_ptr_test
test/unique_ptr_test.cpp
APPEND_LIBRARY_DIRS "$<TARGET_FILE_DIR:test_plugins>"
APPEND_ENV AMENT_PREFIX_PATH=${mock_install_path}
)
if(TARGET ${PROJECT_NAME}_unique_ptr_test)
target_link_libraries(${PROJECT_NAME}_unique_ptr_test ${PROJECT_NAME})
target_include_directories(${PROJECT_NAME}_unique_ptr_test PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test/include>")
add_dependencies(${PROJECT_NAME}_unique_ptr_test "${mock_install_target}")
endif()
ament_add_gtest(${PROJECT_NAME}_utest
test/utest.cpp
APPEND_ENV AMENT_PREFIX_PATH=${mock_install_path}
)
if(TARGET ${PROJECT_NAME}_utest)
# Used, but not linked to test ${PROJECT_NAME}'s exports:
# rcutils::rcutils
target_link_libraries(${PROJECT_NAME}_utest ${PROJECT_NAME})
add_dependencies(${PROJECT_NAME}_utest "${mock_install_target}")
target_include_directories(${PROJECT_NAME}_utest PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test/include>")
endif()
endif()
ament_package(
CONFIG_EXTRAS "pluginlib-extras.cmake"
)