From 9527d4037db8dcba31a61261c009f17767c49bc3 Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Mon, 20 May 2024 21:02:22 +0000 Subject: [PATCH] Switch nav2_regulated_pure_pursuit_controller to modern CMake idioms. Signed-off-by: Chris Lalancette --- .../CMakeLists.txt | 85 ++++++++++++------- .../package.xml | 14 +-- .../test/CMakeLists.txt | 17 +++- 3 files changed, 75 insertions(+), 41 deletions(-) diff --git a/nav2_regulated_pure_pursuit_controller/CMakeLists.txt b/nav2_regulated_pure_pursuit_controller/CMakeLists.txt index e0340a131c..91364c36bc 100644 --- a/nav2_regulated_pure_pursuit_controller/CMakeLists.txt +++ b/nav2_regulated_pure_pursuit_controller/CMakeLists.txt @@ -3,57 +3,61 @@ project(nav2_regulated_pure_pursuit_controller) find_package(ament_cmake REQUIRED) find_package(angles REQUIRED) +find_package(geometry_msgs REQUIRED) find_package(nav2_common REQUIRED) find_package(nav2_core REQUIRED) find_package(nav2_costmap_2d REQUIRED) find_package(nav2_util REQUIRED) -find_package(rclcpp REQUIRED) -find_package(geometry_msgs REQUIRED) find_package(nav_msgs REQUIRED) find_package(pluginlib REQUIRED) +find_package(rclcpp REQUIRED) +find_package(rclcpp_lifecycle REQUIRED) +find_package(rcl_interfaces REQUIRED) +find_package(std_msgs REQUIRED) find_package(tf2 REQUIRED) -find_package(tf2_geometry_msgs REQUIRED) +find_package(tf2_ros REQUIRED) nav2_package() -set(CMAKE_CXX_STANDARD 17) - -include_directories( - include -) - -set(dependencies - rclcpp - geometry_msgs - nav2_costmap_2d - pluginlib - nav_msgs - angles - nav2_util - nav2_core - tf2 - tf2_geometry_msgs -) set(library_name nav2_regulated_pure_pursuit_controller) add_library(${library_name} SHARED - src/regulated_pure_pursuit_controller.cpp - src/collision_checker.cpp - src/parameter_handler.cpp - src/path_handler.cpp) - -ament_target_dependencies(${library_name} - ${dependencies} + src/regulated_pure_pursuit_controller.cpp + src/collision_checker.cpp + src/parameter_handler.cpp + src/path_handler.cpp) +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} + pluginlib::pluginlib + rclcpp::rclcpp + rclcpp_lifecycle::rclcpp_lifecycle + ${rcl_interfaces_TARGETS} + ${std_msgs_TARGETS} + tf2::tf2 + tf2_ros::tf2_ros +) +target_link_libraries(${library_name} PRIVATE + angles::angles ) 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} ) if(BUILD_TESTING) @@ -61,14 +65,31 @@ if(BUILD_TESTING) # the following line skips the linter which checks for copyrights set(ament_cmake_copyright_FOUND TRUE) ament_lint_auto_find_test_dependencies() + + find_package(tf2_geometry_msgs REQUIRED) + + 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 + pluginlib + rclcpp + rclcpp_lifecycle + rcl_interfaces + std_msgs + tf2 + tf2_ros +) +ament_export_targets(${library_name}) pluginlib_export_plugin_description_file(nav2_core nav2_regulated_pure_pursuit_controller.xml) ament_package() - diff --git a/nav2_regulated_pure_pursuit_controller/package.xml b/nav2_regulated_pure_pursuit_controller/package.xml index e690351e19..ff4105b62e 100644 --- a/nav2_regulated_pure_pursuit_controller/package.xml +++ b/nav2_regulated_pure_pursuit_controller/package.xml @@ -9,22 +9,26 @@ Apache-2.0 ament_cmake + nav2_common angles - nav2_common + geometry_msgs nav2_core - nav2_util nav2_costmap_2d - rclcpp - geometry_msgs nav2_msgs + nav2_util pluginlib + rclcpp + rclcpp_lifecycle + rcl_interfaces + std_msgs tf2 - tf2_geometry_msgs + tf2_ros ament_cmake_gtest ament_lint_common ament_lint_auto + tf2_geometry_msgs ament_cmake diff --git a/nav2_regulated_pure_pursuit_controller/test/CMakeLists.txt b/nav2_regulated_pure_pursuit_controller/test/CMakeLists.txt index 3e8d4c5b0a..81ccfc4d28 100644 --- a/nav2_regulated_pure_pursuit_controller/test/CMakeLists.txt +++ b/nav2_regulated_pure_pursuit_controller/test/CMakeLists.txt @@ -3,13 +3,22 @@ ament_add_gtest(test_regulated_pp test_regulated_pp.cpp path_utils/path_utils.cpp ) -ament_target_dependencies(test_regulated_pp - ${dependencies} -) target_link_libraries(test_regulated_pp ${library_name} + ${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 ) # Path utils test ament_add_gtest(test_path_utils path_utils/test_path_utils.cpp path_utils/path_utils.cpp) -ament_target_dependencies(test_path_utils nav_msgs geometry_msgs tf2_geometry_msgs) +target_link_libraries(test_path_utils + ${nav_msgs_TARGETS} + ${geometry_msgs_TARGETS} + tf2::tf2 + tf2_geometry_msgs::tf2_geometry_msgs +)