-
Notifications
You must be signed in to change notification settings - Fork 417
/
CMakeLists.txt
122 lines (112 loc) · 3.92 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
cmake_minimum_required(VERSION 3.5)
project(rclcpp_lifecycle)
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
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(rclcpp REQUIRED)
find_package(rcl_lifecycle REQUIRED)
find_package(rosidl_typesupport_cpp REQUIRED)
find_package(lifecycle_msgs REQUIRED)
### CPP High level library
add_library(rclcpp_lifecycle
src/lifecycle_node.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>")
# specific order: dependents before dependencies
ament_target_dependencies(rclcpp_lifecycle
"rclcpp"
"rcl_lifecycle"
"lifecycle_msgs"
"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)
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})
ament_lint_auto_find_test_dependencies()
ament_add_gtest(test_lifecycle_node test/test_lifecycle_node.cpp)
if(TARGET test_lifecycle_node)
ament_target_dependencies(test_lifecycle_node
"rcl_lifecycle"
"rclcpp"
)
target_link_libraries(test_lifecycle_node ${PROJECT_NAME})
endif()
ament_add_gtest(test_lifecycle_service_client test/test_lifecycle_service_client.cpp)
if(TARGET test_lifecycle_service_client)
ament_target_dependencies(test_lifecycle_service_client
"rcl_lifecycle"
"rclcpp"
)
target_link_libraries(test_lifecycle_service_client ${PROJECT_NAME})
endif()
ament_add_gtest(test_state_machine_info test/test_state_machine_info.cpp)
if(TARGET test_state_machine_info)
ament_target_dependencies(test_state_machine_info
"rcl_lifecycle"
"rclcpp"
)
target_link_libraries(test_state_machine_info ${PROJECT_NAME})
endif()
ament_add_gtest(test_register_custom_callbacks test/test_register_custom_callbacks.cpp)
if(TARGET test_register_custom_callbacks)
ament_target_dependencies(test_register_custom_callbacks
"rcl_lifecycle"
"rclcpp"
)
target_link_libraries(test_register_custom_callbacks ${PROJECT_NAME})
endif()
ament_add_gtest(test_callback_exceptions test/test_callback_exceptions.cpp)
if(TARGET test_callback_exceptions)
ament_target_dependencies(test_callback_exceptions
"rcl_lifecycle"
"rclcpp"
)
target_link_libraries(test_callback_exceptions ${PROJECT_NAME})
endif()
ament_add_gtest(test_state_wrapper test/test_state_wrapper.cpp)
if(TARGET test_state_wrapper)
ament_target_dependencies(test_state_wrapper
"rcl_lifecycle"
"rclcpp"
)
target_link_libraries(test_state_wrapper ${PROJECT_NAME})
endif()
ament_add_gtest(test_transition_wrapper test/test_transition_wrapper.cpp)
if(TARGET test_transition_wrapper)
ament_target_dependencies(test_transition_wrapper
"rcl_lifecycle"
"rclcpp"
)
target_link_libraries(test_transition_wrapper ${PROJECT_NAME})
endif()
endif()
# specific order: dependents before dependencies
ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME})
ament_export_targets(${PROJECT_NAME})
ament_export_dependencies(rclcpp)
ament_export_dependencies(rcl_lifecycle)
ament_export_dependencies(lifecycle_msgs)
ament_package()
install(DIRECTORY include/
DESTINATION include)