Skip to content

Commit

Permalink
Switch nav_2d_utils to use modern CMake idioms. (#4585)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette authored Aug 1, 2024
1 parent 7dcbf76 commit 6751457
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 42 deletions.
91 changes: 53 additions & 38 deletions nav2_dwb_controller/nav_2d_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,78 @@ cmake_minimum_required(VERSION 3.5)
project(nav_2d_utils)

find_package(ament_cmake REQUIRED)
find_package(nav2_common REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(nav_2d_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(nav2_common REQUIRED)
find_package(nav2_msgs REQUIRED)
find_package(nav2_util REQUIRED)
find_package(rclcpp REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(nav2_msgs REQUIRED)
find_package(nav2_util REQUIRED)
find_package(tf2_ros REQUIRED)

nav2_package()

set(dependencies
geometry_msgs
nav_2d_msgs
nav_msgs
std_msgs
rclcpp
tf2
tf2_geometry_msgs
nav2_msgs
nav2_util
nav_2d_msgs
)

include_directories(
include
)

add_library(conversions SHARED
src/conversions.cpp)

ament_target_dependencies(conversions
${dependencies}
target_include_directories(conversions
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)
target_link_libraries(conversions PUBLIC
${geometry_msgs_TARGETS}
${nav_2d_msgs_TARGETS}
${nav_msgs_TARGETS}
rclcpp::rclcpp
tf2::tf2
)
target_link_libraries(conversions PRIVATE
nav2_util::nav2_util_core
tf2_geometry_msgs::tf2_geometry_msgs
)

add_library(path_ops SHARED
src/path_ops.cpp)

ament_target_dependencies(path_ops
${dependencies}
target_include_directories(path_ops
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)
target_link_libraries(path_ops PUBLIC
${nav_2d_msgs_TARGETS}
)
target_link_libraries(path_ops PRIVATE
${geometry_msgs_TARGETS}
)

add_library(tf_help SHARED
src/tf_help.cpp
)

ament_target_dependencies(tf_help
${dependencies}
target_include_directories(tf_help
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)
target_link_libraries(tf_help PUBLIC
conversions
${geometry_msgs_TARGETS}
${nav_2d_msgs_TARGETS}
rclcpp::rclcpp
tf2::tf2
tf2_geometry_msgs::tf2_geometry_msgs
tf2_ros::tf2_ros
)

target_link_libraries(tf_help conversions)

install(TARGETS conversions path_ops tf_help
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
install(DIRECTORY include/
DESTINATION include/
DESTINATION include/${PROJECT_NAME}
)

if(BUILD_TESTING)
Expand All @@ -72,11 +83,15 @@ if(BUILD_TESTING)
ament_lint_auto_find_test_dependencies()

find_package(ament_cmake_gtest REQUIRED)

ament_find_gtest()

add_subdirectory(test)
endif()

ament_export_include_directories(include)
ament_export_include_directories(include/${PROJECT_NAME})
ament_export_libraries(conversions path_ops tf_help)
ament_export_dependencies(${dependencies})
ament_export_dependencies(geometry_msgs nav_2d_msgs nav_msgs rclcpp tf2 tf2_geometry_msgs tf2_ros)
ament_export_targets(${PROJECT_NAME})

ament_package()
7 changes: 4 additions & 3 deletions nav2_dwb_controller/nav_2d_utils/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
<depend>geometry_msgs</depend>
<depend>nav_2d_msgs</depend>
<depend>nav_msgs</depend>
<depend>std_msgs</depend>
<depend>tf2</depend>
<depend>tf2_geometry_msgs</depend>
<depend>nav2_msgs</depend>
<depend>nav2_util</depend>
<depend>rclcpp</depend>
<depend>tf2</depend>
<depend>tf2_geometry_msgs</depend>
<depend>tf2_ros</depend>

<test_depend>ament_lint_common</test_depend>
<test_depend>ament_lint_auto</test_depend>
Expand Down
4 changes: 4 additions & 0 deletions nav2_dwb_controller/nav_2d_utils/src/conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
#include "geometry_msgs/msg/pose2_d.hpp"
#include "geometry_msgs/msg/pose_stamped.hpp"
#include "geometry_msgs/msg/twist.hpp"
#include "nav_msgs/msg/path.hpp"
#include "nav_2d_msgs/msg/twist2_d.hpp"
#include "nav_2d_msgs/msg/pose2_d_stamped.hpp"
#include "nav_2d_msgs/msg/path2_d.hpp"
#include "tf2_geometry_msgs/tf2_geometry_msgs.hpp"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
Expand Down
1 change: 0 additions & 1 deletion nav2_dwb_controller/nav_2d_utils/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ target_link_libraries(path_ops_tests path_ops)

ament_add_gtest(tf_help_tests tf_help_test.cpp)
target_link_libraries(tf_help_tests tf_help conversions)

0 comments on commit 6751457

Please sign in to comment.