From 52ae3e0337261cde440c2f8c47a1d1bb4e070c3a Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Thu, 23 Apr 2020 14:18:51 -0700 Subject: [PATCH] export targets in a addition to include directories / libraries (#1088) Signed-off-by: Dirk Thomas --- rclcpp/CMakeLists.txt | 12 +++++++----- rclcpp_components/CMakeLists.txt | 10 +++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/rclcpp/CMakeLists.txt b/rclcpp/CMakeLists.txt index 1e05814..fbb9105 100644 --- a/rclcpp/CMakeLists.txt +++ b/rclcpp/CMakeLists.txt @@ -26,8 +26,6 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) endif() -include_directories(include) - set(${PROJECT_NAME}_SRCS src/rclcpp/any_executable.cpp src/rclcpp/callback_group.cpp @@ -160,10 +158,12 @@ foreach(interface_file ${interface_files}) include/rclcpp/node_interfaces/get_${interface_name}.hpp) endforeach() -include_directories("${CMAKE_CURRENT_BINARY_DIR}/include") - add_library(${PROJECT_NAME} ${${PROJECT_NAME}_SRCS}) +target_include_directories(${PROJECT_NAME} PUBLIC + "$" + "$" + "$") # specific order: dependents before dependencies ament_target_dependencies(${PROJECT_NAME} "libstatistics_collector" @@ -185,7 +185,7 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE "RCLCPP_BUILDING_LIBRARY") install( - TARGETS ${PROJECT_NAME} + TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin @@ -194,6 +194,7 @@ install( # specific order: dependents before dependencies ament_export_include_directories(include) ament_export_libraries(${PROJECT_NAME}) +ament_export_targets(${PROJECT_NAME}) ament_export_dependencies(libstatistics_collector) ament_export_dependencies(rcl) @@ -255,6 +256,7 @@ if(BUILD_TESTING) endif() ament_add_gtest(test_function_traits test/test_function_traits.cpp) if(TARGET test_function_traits) + target_include_directories(test_function_traits PUBLIC include) ament_target_dependencies(test_function_traits "rcl_interfaces" "rmw" diff --git a/rclcpp_components/CMakeLists.txt b/rclcpp_components/CMakeLists.txt index 3f3f37e..b433096 100644 --- a/rclcpp_components/CMakeLists.txt +++ b/rclcpp_components/CMakeLists.txt @@ -17,13 +17,14 @@ find_package(composition_interfaces REQUIRED) find_package(rclcpp REQUIRED) find_package(rcpputils REQUIRED) -include_directories(include) - add_library( component_manager SHARED src/component_manager.cpp ) +target_include_directories(component_manager PUBLIC + "$" + "$") ament_target_dependencies(component_manager "ament_index_cpp" "class_loader" @@ -68,6 +69,7 @@ if(BUILD_TESTING) set(components "") add_library(test_component SHARED test/components/test_component.cpp) + target_include_directories(test_component PUBLIC include) ament_target_dependencies(test_component "class_loader" "rclcpp") @@ -102,7 +104,7 @@ if(BUILD_TESTING) endif() install( - TARGETS component_manager + TARGETS component_manager EXPORT component_manager ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin @@ -129,6 +131,8 @@ install( # specific order: dependents before dependencies ament_export_include_directories(include) ament_export_libraries(component_manager) +ament_export_targets(component_manager) +ament_export_dependencies(ament_index_cpp) ament_export_dependencies(class_loader) ament_export_dependencies(composition_interfaces) ament_export_dependencies(rclcpp)