From 6501fb4723b7be2ba2e3e00ea3afb759342b4e30 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Mon, 14 Mar 2022 17:30:42 -0700 Subject: [PATCH] Add sensor_msgs_library target and install headers to include/${PROJECT_NAME} Signed-off-by: Shane Loretz --- sensor_msgs/CMakeLists.txt | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/sensor_msgs/CMakeLists.txt b/sensor_msgs/CMakeLists.txt index 8aad975e..bcb5e680 100644 --- a/sensor_msgs/CMakeLists.txt +++ b/sensor_msgs/CMakeLists.txt @@ -55,9 +55,21 @@ rosidl_generate_interfaces(${PROJECT_NAME} ADD_LINTER_TESTS ) -install(DIRECTORY include/${PROJECT_NAME}/ +rosidl_get_typesupport_target(cpp_target "${PROJECT_NAME}" "rosidl_generator_cpp") + +add_library(${PROJECT_NAME}_library INTERFACE) +target_include_directories(${PROJECT_NAME}_library INTERFACE + "$" + "$") +target_link_libraries(${PROJECT_NAME}_library INTERFACE + "${cpp_target}") + +install(DIRECTORY include/ DESTINATION include/${PROJECT_NAME} ) +install( + TARGETS ${PROJECT_NAME}_library EXPORT export_${PROJECT_NAME} +) if(BUILD_TESTING) find_package(ament_cmake_gtest REQUIRED) @@ -73,7 +85,12 @@ if(BUILD_TESTING) target_link_libraries(test_sensor_msgs "${cpp_typesupport_target}") endif() +# Export old-style CMake variables +ament_export_include_directories("include/${PROJECT_NAME}") + +# Export modern CMake targets +ament_export_targets(export_${PROJECT_NAME}) + ament_export_dependencies(rosidl_default_runtime) -ament_export_include_directories(include) ament_package()