From 7ca511ef698340c05551f777ca1f07618849770f Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Mon, 20 May 2024 20:40:06 +0000 Subject: [PATCH] Switch nav2_navfn_planner to modern CMake idioms. Signed-off-by: Chris Lalancette --- nav2_navfn_planner/CMakeLists.txt | 81 ++++++++++++++------------ nav2_navfn_planner/package.xml | 17 +++--- nav2_navfn_planner/test/CMakeLists.txt | 7 ++- 3 files changed, 54 insertions(+), 51 deletions(-) diff --git a/nav2_navfn_planner/CMakeLists.txt b/nav2_navfn_planner/CMakeLists.txt index 624c5168e3..478756e287 100644 --- a/nav2_navfn_planner/CMakeLists.txt +++ b/nav2_navfn_planner/CMakeLists.txt @@ -2,66 +2,58 @@ cmake_minimum_required(VERSION 3.5) project(nav2_navfn_planner) find_package(ament_cmake REQUIRED) +find_package(builtin_interfaces REQUIRED) +find_package(geometry_msgs REQUIRED) find_package(nav2_common REQUIRED) -find_package(rclcpp REQUIRED) -find_package(rclcpp_action REQUIRED) -find_package(rclcpp_lifecycle REQUIRED) -find_package(std_msgs REQUIRED) -find_package(visualization_msgs REQUIRED) -find_package(nav2_util REQUIRED) find_package(nav2_core REQUIRED) -find_package(nav2_msgs REQUIRED) -find_package(nav_msgs REQUIRED) -find_package(geometry_msgs REQUIRED) -find_package(builtin_interfaces REQUIRED) -find_package(tf2_ros REQUIRED) find_package(nav2_costmap_2d REQUIRED) +find_package(nav2_util REQUIRED) +find_package(nav_msgs REQUIRED) find_package(pluginlib REQUIRED) +find_package(rclcpp REQUIRED) +find_package(rclcpp_lifecycle REQUIRED) +find_package(tf2_ros REQUIRED) nav2_package() -include_directories( - include -) - set(library_name nav2_navfn_planner) -set(dependencies - rclcpp - rclcpp_action - rclcpp_lifecycle - std_msgs - visualization_msgs - nav2_util - nav2_msgs - nav_msgs - geometry_msgs - builtin_interfaces - tf2_ros - nav2_costmap_2d - nav2_core - pluginlib -) - add_library(${library_name} SHARED src/navfn_planner.cpp src/navfn.cpp ) - -ament_target_dependencies(${library_name} - ${dependencies} +target_include_directories(${library_name} + PUBLIC + "$" + "$" +) +target_link_libraries(${library_name} PUBLIC + ${geometry_msgs_TARGETS} + nav2_core::nav2_core + nav2_costmap_2d::nav2_costmap_2d_core + nav2_util::nav2_util_core + ${nav_msgs_TARGETS} + rclcpp::rclcpp + rclcpp_lifecycle::rclcpp_lifecycle + ${rcl_interfaces_TARGETS} + tf2_ros::tf2_ros +) +target_link_libraries(${library_name} PRIVATE + ${builtin_interfaces_TARGETS} + pluginlib::pluginlib ) pluginlib_export_plugin_description_file(nav2_core global_planner_plugin.xml) install(TARGETS ${library_name} + EXPORT ${library_name} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin ) install(DIRECTORY include/ - DESTINATION include/ + DESTINATION include/${PROJECT_NAME} ) install(FILES global_planner_plugin.xml @@ -72,10 +64,23 @@ if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) find_package(ament_cmake_gtest REQUIRED) ament_lint_auto_find_test_dependencies() + + ament_find_gtest() add_subdirectory(test) endif() -ament_export_include_directories(include) +ament_export_include_directories(include/${PROJECT_NAME}) ament_export_libraries(${library_name}) -ament_export_dependencies(${dependencies}) +ament_export_dependencies( + geometry_msgs + nav2_core + nav2_costmap_2d + nav2_util + nav_msgs + rclcpp + rclcpp_lifecycle + rcl_interfaces + tf2_ros +) +ament_export_targets(${library_name}) ament_package() diff --git a/nav2_navfn_planner/package.xml b/nav2_navfn_planner/package.xml index 2a9d1ce66a..9ad576e5ab 100644 --- a/nav2_navfn_planner/package.xml +++ b/nav2_navfn_planner/package.xml @@ -10,21 +10,18 @@ BSD-3-Clause ament_cmake + nav2_common - rclcpp - rclcpp_action - rclcpp_lifecycle - visualization_msgs - nav2_util - nav2_msgs - nav_msgs - geometry_msgs builtin_interfaces - nav2_common - tf2_ros + geometry_msgs nav2_costmap_2d nav2_core + nav2_util + nav_msgs pluginlib + rclcpp + rclcpp_lifecycle + tf2_ros ament_lint_common ament_lint_auto diff --git a/nav2_navfn_planner/test/CMakeLists.txt b/nav2_navfn_planner/test/CMakeLists.txt index d415d906ef..5ce1aa12f9 100644 --- a/nav2_navfn_planner/test/CMakeLists.txt +++ b/nav2_navfn_planner/test/CMakeLists.txt @@ -2,9 +2,10 @@ ament_add_gtest(test_dynamic_parameters test_dynamic_parameters.cpp ) -ament_target_dependencies(test_dynamic_parameters - ${dependencies} -) target_link_libraries(test_dynamic_parameters ${library_name} + nav2_costmap_2d::nav2_costmap_2d_core + nav2_util::nav2_util_core + rclcpp::rclcpp + rclcpp_lifecycle::rclcpp_lifecycle )