From a001bfc3c5fc4fdea026cb6599175fa7b429306c Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Tue, 30 Jul 2024 14:16:20 -0400 Subject: [PATCH] Make nav2_core an INTERFACE library. (#4578) That is, it exports header files, but it does not have any implementation itself. Make sure to make an INTERFACE library so downstreams can have access to the header files. Note that this also required a change to nav2_graceful_controller, since it was erroneously getting a visualization_msgs dependency from nav2_core. Signed-off-by: Chris Lalancette --- nav2_core/CMakeLists.txt | 66 ++++++++++++++++--------- nav2_core/package.xml | 15 ++---- nav2_graceful_controller/CMakeLists.txt | 2 + nav2_graceful_controller/package.xml | 1 + 4 files changed, 52 insertions(+), 32 deletions(-) diff --git a/nav2_core/CMakeLists.txt b/nav2_core/CMakeLists.txt index 988f940864..1d0e6b724f 100644 --- a/nav2_core/CMakeLists.txt +++ b/nav2_core/CMakeLists.txt @@ -2,36 +2,47 @@ cmake_minimum_required(VERSION 3.5) project(nav2_core) find_package(ament_cmake REQUIRED) -find_package(nav2_common REQUIRED) -find_package(rclcpp REQUIRED) -find_package(rclcpp_lifecycle REQUIRED) -find_package(std_msgs REQUIRED) find_package(geometry_msgs REQUIRED) +find_package(nav2_behavior_tree REQUIRED) +find_package(nav2_common REQUIRED) find_package(nav2_costmap_2d REQUIRED) -find_package(pluginlib REQUIRED) -find_package(tf2_ros REQUIRED) find_package(nav2_util REQUIRED) find_package(nav_msgs REQUIRED) -find_package(nav2_behavior_tree REQUIRED) +find_package(pluginlib REQUIRED) +find_package(rclcpp REQUIRED) +find_package(rclcpp_lifecycle REQUIRED) +find_package(tf2_ros REQUIRED) nav2_package() -set(dependencies - rclcpp - rclcpp_lifecycle - std_msgs - geometry_msgs - nav2_costmap_2d - pluginlib - visualization_msgs - nav_msgs - tf2_ros - nav2_util - nav2_behavior_tree +add_library(nav2_core INTERFACE) +target_include_directories(nav2_core + INTERFACE + "$" + "$" +) +target_link_libraries(nav2_core INTERFACE + ${geometry_msgs_TARGETS} + nav2_behavior_tree::nav2_behavior_tree + nav2_costmap_2d::nav2_costmap_2d_core + nav2_costmap_2d::nav2_costmap_2d_client + nav2_util::nav2_util_core + ${nav_msgs_TARGETS} + pluginlib::pluginlib + rclcpp::rclcpp + rclcpp_lifecycle::rclcpp_lifecycle + tf2_ros::tf2_ros +) + +install(TARGETS nav2_core + EXPORT nav2_core + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin ) install(DIRECTORY include/ - DESTINATION include/ + DESTINATION include/${PROJECT_NAME} ) if(BUILD_TESTING) @@ -41,7 +52,18 @@ if(BUILD_TESTING) ament_lint_auto_find_test_dependencies() endif() -ament_export_include_directories(include) -ament_export_dependencies(${dependencies}) +ament_export_include_directories(include/${PROJECT_NAME}) +ament_export_dependencies( + geometry_msgs + nav2_behavior_tree + nav2_costmap_2d + nav2_util + nav_msgs + pluginlib + rclcpp + rclcpp_lifecycle + tf2_ros +) +ament_export_targets(nav2_core) ament_package() diff --git a/nav2_core/package.xml b/nav2_core/package.xml index 07a09b2737..55e94f1b9f 100644 --- a/nav2_core/package.xml +++ b/nav2_core/package.xml @@ -11,23 +11,18 @@ ament_cmake nav2_common - rclcpp - rclcpp_lifecycle - std_msgs geometry_msgs + nav2_behavior_tree nav2_costmap_2d - pluginlib + nav2_util nav_msgs + pluginlib + rclcpp + rclcpp_lifecycle tf2_ros - nav2_util - nav2_behavior_tree ament_lint_common ament_lint_auto - ament_cmake_gtest - ament_cmake_pytest - launch - launch_testing ament_cmake diff --git a/nav2_graceful_controller/CMakeLists.txt b/nav2_graceful_controller/CMakeLists.txt index 11a6b89e0b..9cec5b9204 100644 --- a/nav2_graceful_controller/CMakeLists.txt +++ b/nav2_graceful_controller/CMakeLists.txt @@ -14,6 +14,7 @@ find_package(tf2 REQUIRED) find_package(tf2_geometry_msgs REQUIRED) find_package(nav_2d_utils REQUIRED) find_package(angles REQUIRED) +find_package(visualization_msgs REQUIRED) nav2_package() @@ -33,6 +34,7 @@ set(dependencies tf2_geometry_msgs nav_2d_utils angles + visualization_msgs ) # Add Smooth Control Law as library diff --git a/nav2_graceful_controller/package.xml b/nav2_graceful_controller/package.xml index 4fadf93747..b6deb17b72 100644 --- a/nav2_graceful_controller/package.xml +++ b/nav2_graceful_controller/package.xml @@ -21,6 +21,7 @@ tf2_geometry_msgs nav_2d_utils angles + visualization_msgs ament_lint_auto ament_lint_common