Skip to content

Commit

Permalink
Make nav2_core an INTERFACE library.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
clalancette committed Jul 30, 2024
1 parent 57415d6 commit 33a3c48
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 32 deletions.
66 changes: 44 additions & 22 deletions nav2_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)
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)
Expand All @@ -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()
15 changes: 5 additions & 10 deletions nav2_core/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,18 @@
<buildtool_depend>ament_cmake</buildtool_depend>
<build_depend>nav2_common</build_depend>

<depend>rclcpp</depend>
<depend>rclcpp_lifecycle</depend>
<depend>std_msgs</depend>
<depend>geometry_msgs</depend>
<depend>nav2_behavior_tree</depend>
<depend>nav2_costmap_2d</depend>
<depend>pluginlib</depend>
<depend>nav2_util</depend>
<depend>nav_msgs</depend>
<depend>pluginlib</depend>
<depend>rclcpp</depend>
<depend>rclcpp_lifecycle</depend>
<depend>tf2_ros</depend>
<depend>nav2_util</depend>
<depend>nav2_behavior_tree</depend>

<test_depend>ament_lint_common</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_cmake_gtest</test_depend>
<test_depend>ament_cmake_pytest</test_depend>
<test_depend>launch</test_depend>
<test_depend>launch_testing</test_depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down
2 changes: 2 additions & 0 deletions nav2_graceful_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -33,6 +34,7 @@ set(dependencies
tf2_geometry_msgs
nav_2d_utils
angles
visualization_msgs
)

# Add Smooth Control Law as library
Expand Down
1 change: 1 addition & 0 deletions nav2_graceful_controller/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<depend>tf2_geometry_msgs</depend>
<depend>nav_2d_utils</depend>
<depend>angles</depend>
<depend>visualization_msgs</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
Expand Down

0 comments on commit 33a3c48

Please sign in to comment.