-
Notifications
You must be signed in to change notification settings - Fork 528
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
178 lines (160 loc) · 6.45 KB
/
CMakeLists.txt
File metadata and controls
178 lines (160 loc) · 6.45 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
cmake_minimum_required(VERSION 3.20)
project(rclcpp_lifecycle)
# 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 -Wnon-virtual-dtor -Woverloaded-virtual)
endif()
find_package(ament_cmake_ros REQUIRED)
find_package(lifecycle_msgs REQUIRED)
find_package(rcl REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rcl_interfaces REQUIRED)
find_package(rcl_lifecycle REQUIRED)
find_package(rcutils REQUIRED)
find_package(rosidl_typesupport_cpp REQUIRED)
### CPP High level library
add_library(rclcpp_lifecycle
src/lifecycle_node.cpp
src/lifecycle_node_interface_impl.cpp
src/managed_entity.cpp
src/node_interfaces/lifecycle_node_interface.cpp
src/state.cpp
src/transition.cpp
)
target_include_directories(${PROJECT_NAME}
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
target_link_libraries(${PROJECT_NAME}
lifecycle_msgs::lifecycle_msgs
rcl::rcl
rclcpp::rclcpp
rcl_interfaces::rcl_interfaces
rcl_lifecycle::rcl_lifecycle
rcutils::rcutils
rosidl_typesupport_cpp::rosidl_typesupport_cpp
)
# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(rclcpp_lifecycle PRIVATE "RCLCPP_LIFECYCLE_BUILDING_DLL")
install(TARGETS
rclcpp_lifecycle EXPORT rclcpp_lifecycle
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
install(DIRECTORY include/
DESTINATION include/${PROJECT_NAME})
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# Give cppcheck hints about macro definitions coming from outside this package
set(ament_cmake_cppcheck_ADDITIONAL_INCLUDE_DIRS ${rclcpp_INCLUDE_DIRS})
list(APPEND AMENT_LINT_AUTO_EXCLUDE "ament_cmake_cppcheck")
ament_lint_auto_find_test_dependencies()
find_package(ament_cmake_cppcheck REQUIRED)
ament_cppcheck()
set_tests_properties(cppcheck PROPERTIES TIMEOUT 360)
find_package(performance_test_fixture REQUIRED)
add_performance_test(
benchmark_lifecycle_client
test/benchmark/benchmark_lifecycle_client.cpp)
if(TARGET benchmark_lifecycle_client)
target_link_libraries(benchmark_lifecycle_client ${PROJECT_NAME} rclcpp::rclcpp)
endif()
add_performance_test(
benchmark_lifecycle_node
test/benchmark/benchmark_lifecycle_node.cpp)
if(TARGET benchmark_lifecycle_node)
target_link_libraries(benchmark_lifecycle_node ${PROJECT_NAME} rclcpp::rclcpp)
endif()
add_performance_test(
benchmark_state
test/benchmark/benchmark_state.cpp)
if(TARGET benchmark_state)
target_link_libraries(benchmark_state ${PROJECT_NAME})
endif()
add_performance_test(
benchmark_transition
test/benchmark/benchmark_transition.cpp)
if(TARGET benchmark_transition)
target_link_libraries(benchmark_transition ${PROJECT_NAME})
endif()
ament_add_gtest(test_lifecycle_node test/test_lifecycle_node.cpp TIMEOUT 120)
ament_add_test_label(test_lifecycle_node mimick)
if(TARGET test_lifecycle_node)
target_link_libraries(test_lifecycle_node ${PROJECT_NAME} mimick rcl_lifecycle::rcl_lifecycle rclcpp::rclcpp rcutils::rcutils)
endif()
ament_add_gtest(test_lifecycle_node_errors test/test_lifecycle_node_errors.cpp)
ament_add_test_label(test_lifecycle_node_errors mimick)
if(TARGET test_lifecycle_node_errors)
target_link_libraries(test_lifecycle_node_errors ${PROJECT_NAME} mimick rcl_lifecycle::rcl_lifecycle)
endif()
ament_add_gtest(test_lifecycle_publisher test/test_lifecycle_publisher.cpp)
if(TARGET test_lifecycle_publisher)
target_link_libraries(test_lifecycle_publisher ${PROJECT_NAME} rcl_lifecycle::rcl_lifecycle rclcpp::rclcpp test_msgs::test_msgs)
endif()
ament_add_gtest(test_lifecycle_service_client test/test_lifecycle_service_client.cpp TIMEOUT 120)
ament_add_test_label(test_lifecycle_service_client mimick)
if(TARGET test_lifecycle_service_client)
target_link_libraries(test_lifecycle_service_client
${PROJECT_NAME}
mimick
rcl_lifecycle::rcl_lifecycle
rclcpp::rclcpp
rcpputils::rcpputils
rcutils::rcutils)
endif()
ament_add_gtest(test_client test/test_client.cpp TIMEOUT 120)
ament_add_test_label(test_client mimick)
if(TARGET test_client)
target_link_libraries(test_client
${PROJECT_NAME}
mimick
rcl_interfaces::rcl_interfaces
rclcpp::rclcpp)
endif()
ament_add_gtest(test_service test/test_service.cpp TIMEOUT 120)
ament_add_test_label(test_service mimick)
if(TARGET test_service)
target_link_libraries(test_service
${PROJECT_NAME}
mimick
test_msgs::test_msgs
rclcpp::rclcpp)
endif()
ament_add_gtest(test_state_machine_info test/test_state_machine_info.cpp)
if(TARGET test_state_machine_info)
target_link_libraries(test_state_machine_info ${PROJECT_NAME} rcl_lifecycle::rcl_lifecycle rclcpp::rclcpp)
endif()
ament_add_gtest(test_register_custom_callbacks test/test_register_custom_callbacks.cpp)
if(TARGET test_register_custom_callbacks)
target_link_libraries(test_register_custom_callbacks ${PROJECT_NAME} rcl_lifecycle::rcl_lifecycle rclcpp::rclcpp)
endif()
ament_add_gtest(test_callback_exceptions test/test_callback_exceptions.cpp)
if(TARGET test_callback_exceptions)
target_link_libraries(test_callback_exceptions ${PROJECT_NAME} rcl_lifecycle::rcl_lifecycle rclcpp::rclcpp)
endif()
ament_add_gtest(test_state_wrapper test/test_state_wrapper.cpp)
if(TARGET test_state_wrapper)
target_link_libraries(test_state_wrapper ${PROJECT_NAME} rcl_lifecycle::rcl_lifecycle rclcpp::rclcpp)
endif()
ament_add_gtest(test_transition_wrapper test/test_transition_wrapper.cpp)
ament_add_test_label(test_transition_wrapper mimick)
if(TARGET test_transition_wrapper)
target_link_libraries(test_transition_wrapper ${PROJECT_NAME} mimick rcl_lifecycle::rcl_lifecycle rclcpp::rclcpp rcutils::rcutils)
target_compile_definitions(test_transition_wrapper
PUBLIC RCUTILS_ENABLE_FAULT_INJECTION
)
endif()
endif()
# Export old-style CMake variables
ament_export_include_directories("include/${PROJECT_NAME}")
ament_export_libraries(${PROJECT_NAME})
# Export modern CMake targets
ament_export_targets(${PROJECT_NAME})
# Export dependencies
ament_export_dependencies(lifecycle_msgs rcl rclcpp rcl_interfaces rcl_lifecycle rcutils rosidl_typesupport_cpp)
ament_package()