2016-12-14 09:29:27 -08:00
|
|
|
cmake_minimum_required(VERSION 3.5)
|
|
|
|
|
|
|
|
project(rclcpp_lifecycle)
|
|
|
|
|
2017-06-15 13:48:42 -07:00
|
|
|
# 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")
|
2020-06-01 23:58:48 -03:00
|
|
|
add_compile_options(-Wall -Wextra -Wpedantic -Wnon-virtual-dtor -Woverloaded-virtual)
|
2016-12-14 09:29:27 -08:00
|
|
|
endif()
|
|
|
|
|
2018-02-26 09:46:44 -08:00
|
|
|
find_package(ament_cmake_ros REQUIRED)
|
2016-12-14 09:29:27 -08:00
|
|
|
find_package(rclcpp REQUIRED)
|
|
|
|
find_package(rcl_lifecycle REQUIRED)
|
2018-07-05 13:01:23 -07:00
|
|
|
find_package(rosidl_typesupport_cpp REQUIRED)
|
2016-12-14 09:29:27 -08:00
|
|
|
find_package(lifecycle_msgs REQUIRED)
|
|
|
|
|
2017-01-05 12:13:58 -08:00
|
|
|
### 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
|
|
|
|
)
|
2020-04-27 10:30:33 -07:00
|
|
|
target_include_directories(${PROJECT_NAME}
|
|
|
|
PUBLIC
|
|
|
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
|
|
|
"$<INSTALL_INTERFACE:include>")
|
2018-03-22 16:26:42 -07:00
|
|
|
# specific order: dependents before dependencies
|
2017-01-05 12:13:58 -08:00
|
|
|
ament_target_dependencies(rclcpp_lifecycle
|
2018-03-22 16:26:42 -07:00
|
|
|
"rclcpp"
|
2017-01-05 12:13:58 -08:00
|
|
|
"rcl_lifecycle"
|
2018-07-05 13:01:23 -07:00
|
|
|
"lifecycle_msgs"
|
|
|
|
"rosidl_typesupport_cpp"
|
|
|
|
)
|
2017-01-05 12:13:58 -08:00
|
|
|
|
|
|
|
# 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
|
2020-04-27 10:30:33 -07:00
|
|
|
rclcpp_lifecycle EXPORT rclcpp_lifecycle
|
2017-01-05 12:13:58 -08:00
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
RUNTIME DESTINATION bin)
|
2016-12-14 09:29:27 -08:00
|
|
|
|
|
|
|
if(BUILD_TESTING)
|
|
|
|
find_package(ament_lint_auto REQUIRED)
|
2020-03-04 09:05:21 -08:00
|
|
|
# Give cppcheck hints about macro definitions coming from outside this package
|
|
|
|
set(ament_cmake_cppcheck_ADDITIONAL_INCLUDE_DIRS ${rclcpp_INCLUDE_DIRS})
|
2016-12-14 09:29:27 -08:00
|
|
|
ament_lint_auto_find_test_dependencies()
|
|
|
|
|
|
|
|
ament_add_gtest(test_lifecycle_node test/test_lifecycle_node.cpp)
|
|
|
|
if(TARGET test_lifecycle_node)
|
2019-03-19 09:23:10 -03:00
|
|
|
ament_target_dependencies(test_lifecycle_node
|
|
|
|
"rcl_lifecycle"
|
|
|
|
"rclcpp"
|
2020-09-18 10:41:20 -07:00
|
|
|
"rcutils"
|
2016-12-14 09:29:27 -08:00
|
|
|
)
|
2020-09-18 10:41:20 -07:00
|
|
|
target_link_libraries(test_lifecycle_node ${PROJECT_NAME} mimick)
|
|
|
|
endif()
|
|
|
|
ament_add_gtest(test_lifecycle_publisher test/test_lifecycle_publisher.cpp)
|
|
|
|
if(TARGET test_lifecycle_publisher)
|
|
|
|
ament_target_dependencies(test_lifecycle_publisher
|
|
|
|
"rcl_lifecycle"
|
|
|
|
"rclcpp"
|
|
|
|
"test_msgs"
|
|
|
|
)
|
|
|
|
target_link_libraries(test_lifecycle_publisher ${PROJECT_NAME})
|
2016-12-14 09:29:27 -08:00
|
|
|
endif()
|
2020-04-30 10:29:45 -07:00
|
|
|
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"
|
2020-09-18 10:41:20 -07:00
|
|
|
"rcutils"
|
2020-04-30 10:29:45 -07:00
|
|
|
)
|
2020-09-18 10:41:20 -07:00
|
|
|
target_link_libraries(test_lifecycle_service_client ${PROJECT_NAME} mimick)
|
2020-04-30 10:29:45 -07:00
|
|
|
endif()
|
2016-12-14 09:29:27 -08:00
|
|
|
ament_add_gtest(test_state_machine_info test/test_state_machine_info.cpp)
|
|
|
|
if(TARGET test_state_machine_info)
|
2019-03-19 09:23:10 -03:00
|
|
|
ament_target_dependencies(test_state_machine_info
|
|
|
|
"rcl_lifecycle"
|
|
|
|
"rclcpp"
|
2016-12-14 09:29:27 -08:00
|
|
|
)
|
|
|
|
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)
|
2019-03-19 09:23:10 -03:00
|
|
|
ament_target_dependencies(test_register_custom_callbacks
|
|
|
|
"rcl_lifecycle"
|
|
|
|
"rclcpp"
|
2016-12-14 09:29:27 -08:00
|
|
|
)
|
|
|
|
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)
|
2019-03-19 09:23:10 -03:00
|
|
|
ament_target_dependencies(test_callback_exceptions
|
|
|
|
"rcl_lifecycle"
|
|
|
|
"rclcpp"
|
2016-12-14 09:29:27 -08:00
|
|
|
)
|
|
|
|
target_link_libraries(test_callback_exceptions ${PROJECT_NAME})
|
|
|
|
endif()
|
2017-05-25 19:52:50 -07:00
|
|
|
ament_add_gtest(test_state_wrapper test/test_state_wrapper.cpp)
|
|
|
|
if(TARGET test_state_wrapper)
|
2019-03-19 09:23:10 -03:00
|
|
|
ament_target_dependencies(test_state_wrapper
|
|
|
|
"rcl_lifecycle"
|
|
|
|
"rclcpp"
|
2017-05-25 19:52:50 -07:00
|
|
|
)
|
|
|
|
target_link_libraries(test_state_wrapper ${PROJECT_NAME})
|
|
|
|
endif()
|
2017-12-05 20:22:57 -08:00
|
|
|
ament_add_gtest(test_transition_wrapper test/test_transition_wrapper.cpp)
|
|
|
|
if(TARGET test_transition_wrapper)
|
2019-03-19 09:23:10 -03:00
|
|
|
ament_target_dependencies(test_transition_wrapper
|
|
|
|
"rcl_lifecycle"
|
|
|
|
"rclcpp"
|
2020-09-18 10:41:20 -07:00
|
|
|
"rcutils"
|
|
|
|
)
|
|
|
|
target_link_libraries(test_transition_wrapper ${PROJECT_NAME} mimick)
|
|
|
|
target_compile_definitions(test_transition_wrapper
|
|
|
|
PUBLIC RCUTILS_ENABLE_FAULT_INJECTION
|
2017-12-05 20:22:57 -08:00
|
|
|
)
|
|
|
|
endif()
|
2016-12-14 09:29:27 -08:00
|
|
|
endif()
|
|
|
|
|
2018-03-22 16:26:42 -07:00
|
|
|
# specific order: dependents before dependencies
|
|
|
|
ament_export_include_directories(include)
|
|
|
|
ament_export_libraries(${PROJECT_NAME})
|
2020-04-27 10:30:33 -07:00
|
|
|
ament_export_targets(${PROJECT_NAME})
|
2016-12-14 09:29:27 -08:00
|
|
|
ament_export_dependencies(rclcpp)
|
|
|
|
ament_export_dependencies(rcl_lifecycle)
|
|
|
|
ament_export_dependencies(lifecycle_msgs)
|
|
|
|
ament_package()
|
|
|
|
|
|
|
|
install(DIRECTORY include/
|
|
|
|
DESTINATION include)
|