Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sensor_msgs_library target and install headers to include/${PROJECT_NAME} #178

Merged
merged 1 commit into from
Mar 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions sensor_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
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)
Expand All @@ -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()