Skip to content

Commit

Permalink
Switch opennav_docking_bt to modern CMake idioms. (#4631)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Lalancette <clalancette@gmail.com>
  • Loading branch information
clalancette authored Aug 20, 2024
1 parent ebd9ee1 commit e722563
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 47 deletions.
82 changes: 44 additions & 38 deletions nav2_docking/opennav_docking_bt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,56 @@ cmake_minimum_required(VERSION 3.5)
project(opennav_docking_bt)

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(std_msgs REQUIRED)
find_package(nav2_util REQUIRED)
find_package(nav2_msgs REQUIRED)
find_package(nav2_core REQUIRED)
find_package(behaviortree_cpp REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(nav2_behavior_tree REQUIRED)
find_package(nav2_common REQUIRED)
find_package(nav2_core REQUIRED)
find_package(nav2_msgs REQUIRED)
find_package(nav2_util REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(behaviortree_cpp REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)

# potentially replace with nav2_common, nav2_package()
set(CMAKE_CXX_STANDARD 17)
add_compile_options(-Wall -Wextra -Wpedantic -Werror -Wdeprecated -fPIC -Wshadow -Wnull-dereference)
nav2_package()

include_directories(
include
add_library(opennav_dock_action_bt_node SHARED src/dock_robot.cpp)
target_include_directories(opennav_dock_action_bt_node
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)

set(dependencies
rclcpp
rclcpp_action
std_msgs
nav2_util
nav2_msgs
nav2_core
nav2_behavior_tree
nav_msgs
geometry_msgs
behaviortree_cpp
target_compile_definitions(opennav_dock_action_bt_node PRIVATE BT_PLUGIN_EXPORT)
target_link_libraries(opennav_dock_action_bt_node PUBLIC
behaviortree_cpp::behaviortree_cpp
${geometry_msgs_TARGETS}
nav2_behavior_tree::nav2_behavior_tree
${nav2_msgs_TARGETS}
)

add_library(opennav_dock_action_bt_node SHARED src/dock_robot.cpp)
list(APPEND plugin_libs opennav_dock_action_bt_node)
add_library(opennav_undock_action_bt_node SHARED src/undock_robot.cpp)
list(APPEND plugin_libs opennav_undock_action_bt_node)

foreach(bt_plugin ${plugin_libs})
ament_target_dependencies(${bt_plugin} ${dependencies})
target_compile_definitions(${bt_plugin} PRIVATE BT_PLUGIN_EXPORT)
endforeach()
target_include_directories(opennav_undock_action_bt_node
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)
target_compile_definitions(opennav_undock_action_bt_node PRIVATE BT_PLUGIN_EXPORT)
target_link_libraries(opennav_undock_action_bt_node PUBLIC
behaviortree_cpp::behaviortree_cpp
${geometry_msgs_TARGETS}
nav2_behavior_tree::nav2_behavior_tree
${nav2_msgs_TARGETS}
)

install(TARGETS ${plugin_libs}
install(TARGETS opennav_dock_action_bt_node opennav_undock_action_bt_node
EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

install(DIRECTORY include/
DESTINATION include/
DESTINATION include/${PROJECT_NAME}
)

install(DIRECTORY behavior_trees DESTINATION share/${PROJECT_NAME})
Expand All @@ -63,7 +63,13 @@ if(BUILD_TESTING)
add_subdirectory(test)
endif()

ament_export_include_directories(include)
ament_export_libraries(${plugin_libs})
ament_export_dependencies(${dependencies})
ament_export_include_directories(include/${PROJECT_NAME})
ament_export_libraries(opennav_dock_action_bt_node opennav_undock_action_bt_node)
ament_export_dependencies(
behaviortree_cpp
geometry_msgs
nav2_behavior_tree
nav2_msgs
)
ament_export_targets(${PROJECT_NAME})
ament_package()
11 changes: 6 additions & 5 deletions nav2_docking/opennav_docking_bt/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
<license>Apache-2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<build_depend>nav2_common</build_depend>

<depend>rclcpp</depend>
<depend>rclcpp_action</depend>
<depend>behaviortree_cpp</depend>
<depend>geometry_msgs</depend>
<depend>nav2_behavior_tree</depend>
<depend>nav2_util</depend>
<depend>nav2_core</depend>
<depend>nav2_msgs</depend>
<depend>nav2_util</depend>
<depend>nav_msgs</depend>
<depend>geometry_msgs</depend>
<depend>behaviortree_cpp</depend>
<depend>rclcpp</depend>
<depend>rclcpp_action</depend>

<test_depend>ament_lint_common</test_depend>
<test_depend>ament_lint_auto</test_depend>
Expand Down
20 changes: 16 additions & 4 deletions nav2_docking/opennav_docking_bt/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
# Cancel test
ament_add_gtest(test_dock_robot test_dock_robot.cpp)
target_link_libraries(test_dock_robot opennav_dock_action_bt_node)
ament_target_dependencies(test_dock_robot ${dependencies})
target_link_libraries(test_dock_robot
behaviortree_cpp::behaviortree_cpp
${geometry_msgs_TARGETS}
${nav2_msgs_TARGETS}
opennav_dock_action_bt_node
rclcpp::rclcpp
rclcpp_action::rclcpp_action
)

# Make command test
ament_add_gtest(test_undock_robot test_undock_robot.cpp)
target_link_libraries(test_undock_robot opennav_undock_action_bt_node)
ament_target_dependencies(test_undock_robot ${dependencies})
target_link_libraries(test_undock_robot
behaviortree_cpp::behaviortree_cpp
${geometry_msgs_TARGETS}
${nav2_msgs_TARGETS}
opennav_undock_action_bt_node
rclcpp::rclcpp
rclcpp_action::rclcpp_action
)

0 comments on commit e722563

Please sign in to comment.