Skip to content

Commit

Permalink
Update CMakeLists.txt to use modern idioms.
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Tudela <[email protected]>
  • Loading branch information
ajtudela committed Sep 17, 2024
1 parent c2e15c3 commit c2885d7
Show file tree
Hide file tree
Showing 45 changed files with 507 additions and 291 deletions.
1 change: 1 addition & 0 deletions scitos2_behavior_tree/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Changelog for package scitos2_behavior_tree
* Add generate_scitos2_tree_nodes_xml.
* Add unit testing.
* The utils folder in test is just a copy of nav2_behavior_tree/test/utils because Rolling CI is currently broken. This will be removed once Rolling CI is fixed.
* Update CMakeLists.txt to use modern idioms.

0.3.0 (26-04-2023)
------------------
Expand Down
96 changes: 64 additions & 32 deletions scitos2_behavior_tree/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ if(NOT CMAKE_CXX_STANDARD)
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# add_compile_options(-Wall -Wextra -Wpedantic -Werror -Wdeprecated -fPIC -Wshadow -Wnull-dereference)
add_compile_options(-Wall -Wextra -Wpedantic -Wdeprecated -fPIC -Wshadow -Wnull-dereference)
add_compile_options(-Wall -Wextra -Wpedantic -Werror -Wdeprecated -fPIC -Wnull-dereference)
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-Wnon-virtual-dtor>")
endif()

Expand Down Expand Up @@ -51,49 +50,70 @@ endif()
# ###############################################
# # Find ament macros and libraries
find_package(ament_cmake REQUIRED)
find_package(behaviortree_cpp_v3 REQUIRED)
find_package(nav2_behavior_tree REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)
find_package(scitos2_msgs REQUIRED)
find_package(behaviortree_cpp_v3 REQUIRED)
find_package(nav2_behavior_tree REQUIRED)

# ##########
# # Build ##
# ##########
# # Specify additional locations of header files
# # Your package locations should be listed before other locations
include_directories(
include
add_library(scitos2_is_bumper_activated_condition_bt_node SHARED src/condition/is_bumper_activated_condition.cpp)
target_include_directories(scitos2_is_bumper_activated_condition_bt_node PUBLIC
"$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)

set(dependencies
rclcpp
rclcpp_action
rclcpp_lifecycle
scitos2_msgs
behaviortree_cpp_v3
nav2_behavior_tree
target_link_libraries(scitos2_is_bumper_activated_condition_bt_node
PUBLIC
rclcpp::rclcpp
${scitos2_msgs_TARGETS}
)

add_library(scitos2_is_bumper_activated_condition_bt_node SHARED src/condition/is_bumper_activated_condition.cpp)
list(APPEND plugin_libs scitos2_is_bumper_activated_condition_bt_node)
ament_target_dependencies(scitos2_is_bumper_activated_condition_bt_node
PUBLIC
behaviortree_cpp_v3
) # TODO(ajtudela): Fix this in jazzy
target_compile_definitions(scitos2_is_bumper_activated_condition_bt_node PRIVATE BT_PLUGIN_EXPORT)

add_library(scitos2_emergency_stop_service_bt_node SHARED src/action/emergency_stop_service.cpp)
list(APPEND plugin_libs scitos2_emergency_stop_service_bt_node)
target_include_directories(scitos2_emergency_stop_service_bt_node PUBLIC
"$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)
target_link_libraries(scitos2_emergency_stop_service_bt_node
PUBLIC
${scitos2_msgs_TARGETS}
)
ament_target_dependencies(scitos2_emergency_stop_service_bt_node
PUBLIC
nav2_behavior_tree
) # TODO(ajtudela): Fix this in jazzy
target_compile_definitions(scitos2_emergency_stop_service_bt_node PRIVATE BT_PLUGIN_EXPORT)

add_library(scitos2_reset_motor_stop_service_bt_node SHARED src/action/reset_motor_stop_service.cpp)
list(APPEND plugin_libs scitos2_reset_motor_stop_service_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(scitos2_reset_motor_stop_service_bt_node PUBLIC
"$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)
target_link_libraries(scitos2_reset_motor_stop_service_bt_node
PUBLIC
${scitos2_msgs_TARGETS}
)
ament_target_dependencies(scitos2_reset_motor_stop_service_bt_node
PUBLIC
nav2_behavior_tree
) # TODO(ajtudela): Fix this in jazzy
target_compile_definitions(scitos2_reset_motor_stop_service_bt_node PRIVATE BT_PLUGIN_EXPORT)

# ############
# # Install ##
# ############
install(TARGETS ${plugin_libs}
install(TARGETS
scitos2_is_bumper_activated_condition_bt_node
scitos2_emergency_stop_service_bt_node
scitos2_reset_motor_stop_service_bt_node
EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
Expand All @@ -104,14 +124,14 @@ set(GENERATED_DIR ${CMAKE_CURRENT_BINARY_DIR}/gen)
configure_file(plugins_list.hpp.in ${GENERATED_DIR}/plugins_list.hpp)

add_executable(generate_scitos2_tree_nodes_xml src/generate_scitos2_tree_nodes_xml.cpp)
ament_target_dependencies(generate_scitos2_tree_nodes_xml ${dependencies})
ament_target_dependencies(generate_scitos2_tree_nodes_xml PUBLIC behaviortree_cpp_v3) # TODO(ajtudela): Fix this in jazzy

# allow generate_scitos2_tree_nodes_xml to find plugins_list.hpp
target_include_directories(generate_scitos2_tree_nodes_xml PRIVATE ${GENERATED_DIR})
install(TARGETS generate_scitos2_tree_nodes_xml DESTINATION lib/${PROJECT_NAME})

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

install(DIRECTORY test/utils/
Expand All @@ -137,7 +157,19 @@ endif()
# ##################################
# # ament specific configuration ##
# ##################################
ament_export_include_directories(include)
ament_export_libraries(${plugin_libs})
ament_export_dependencies(${dependencies})
ament_export_include_directories(include/${PROJECT_NAME})
ament_export_libraries(
scitos2_is_bumper_activated_condition_bt_node
scitos2_emergency_stop_service_bt_node
scitos2_reset_motor_stop_service_bt_node
)
ament_export_dependencies(
behaviortree_cpp_v3
nav2_behavior_tree
rclcpp
rclcpp_action
rclcpp_lifecycle
scitos2_msgs
)
ament_export_targets(${PROJECT_NAME})
ament_package()
4 changes: 2 additions & 2 deletions scitos2_behavior_tree/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
<license>Apache-2.0</license>
<author email="[email protected]">Alberto Tudela</author>
<buildtool_depend>ament_cmake</buildtool_depend>
<depend>behaviortree_cpp_v3</depend>
<depend>nav2_behavior_tree</depend>
<depend>rclcpp</depend>
<depend>rclcpp_action</depend>
<depend>rclcpp_lifecycle</depend>
<depend>scitos2_msgs</depend>
<depend>behaviortree_cpp_v3</depend>
<depend>nav2_behavior_tree</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
Expand Down
7 changes: 5 additions & 2 deletions scitos2_behavior_tree/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ add_subdirectory(condition)

# Test register
ament_add_gtest(test_register
test_register.cpp
test_register.cpp
)
target_link_libraries(test_register
rclcpp::rclcpp
)
ament_target_dependencies(test_register
${dependencies}
behaviortree_cpp_v3
)
12 changes: 6 additions & 6 deletions scitos2_behavior_tree/test/action/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
ament_add_gtest(test_scitos2_action_emergency_stop_service
test_emergency_stop_service.cpp
)
ament_target_dependencies(test_scitos2_action_emergency_stop_service
${dependencies}
)
target_link_libraries(test_scitos2_action_emergency_stop_service
scitos2_emergency_stop_service_bt_node
)
ament_target_dependencies(test_scitos2_action_emergency_stop_service
behaviortree_cpp_v3
)

# Test for the reset motor stop service
ament_add_gtest(test_scitos2_action_reset_motor_stop_service
test_reset_motor_stop_service.cpp
)
ament_target_dependencies(test_scitos2_action_reset_motor_stop_service
${dependencies}
)
target_link_libraries(test_scitos2_action_reset_motor_stop_service
scitos2_reset_motor_stop_service_bt_node
)
ament_target_dependencies(test_scitos2_action_reset_motor_stop_service
behaviortree_cpp_v3
)
13 changes: 10 additions & 3 deletions scitos2_behavior_tree/test/condition/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
find_package(geometry_msgs REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(tf2_msgs REQUIRED)
find_package(tf2_ros REQUIRED)

# Test for is bumper activated condition
ament_add_gtest(test_scitos2_condition_is_bumper_activated
test_is_bumper_activated_condition.cpp
)
ament_target_dependencies(test_scitos2_condition_is_bumper_activated
${dependencies}
)
target_link_libraries(test_scitos2_condition_is_bumper_activated
${geometry_msgs_TARGETS}
scitos2_is_bumper_activated_condition_bt_node
${scitos2_msgs_TARGETS}
rclcpp_action::rclcpp_action
${tf2_msgs_TARGETS}
tf2_ros::tf2_ros
)
1 change: 1 addition & 0 deletions scitos2_charging_dock/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ Changelog for package scitos2_charging_dock
* Initial release.
* Create README.md.
* Redo the package to use the new docking system.
* Update CMakeLists.txt to use modern idioms.
* Contributors: Alberto Tudela
Loading

0 comments on commit c2885d7

Please sign in to comment.