Skip to content

Commit c2885d7

Browse files
committed
Update CMakeLists.txt to use modern idioms.
Signed-off-by: Alberto Tudela <ajtudela@gmail.com>
1 parent c2e15c3 commit c2885d7

45 files changed

Lines changed: 507 additions & 291 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

scitos2_behavior_tree/CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Changelog for package scitos2_behavior_tree
99
* Add generate_scitos2_tree_nodes_xml.
1010
* Add unit testing.
1111
* 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.
12+
* Update CMakeLists.txt to use modern idioms.
1213

1314
0.3.0 (26-04-2023)
1415
------------------

scitos2_behavior_tree/CMakeLists.txt

Lines changed: 64 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ if(NOT CMAKE_CXX_STANDARD)
2121
endif()
2222

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

@@ -51,49 +50,70 @@ endif()
5150
# ###############################################
5251
# # Find ament macros and libraries
5352
find_package(ament_cmake REQUIRED)
53+
find_package(behaviortree_cpp_v3 REQUIRED)
54+
find_package(nav2_behavior_tree REQUIRED)
5455
find_package(rclcpp REQUIRED)
5556
find_package(rclcpp_action REQUIRED)
5657
find_package(rclcpp_lifecycle REQUIRED)
5758
find_package(scitos2_msgs REQUIRED)
58-
find_package(behaviortree_cpp_v3 REQUIRED)
59-
find_package(nav2_behavior_tree REQUIRED)
6059

6160
# ##########
6261
# # Build ##
6362
# ##########
64-
# # Specify additional locations of header files
65-
# # Your package locations should be listed before other locations
66-
include_directories(
67-
include
63+
add_library(scitos2_is_bumper_activated_condition_bt_node SHARED src/condition/is_bumper_activated_condition.cpp)
64+
target_include_directories(scitos2_is_bumper_activated_condition_bt_node PUBLIC
65+
"$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>"
66+
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
6867
)
69-
70-
set(dependencies
71-
rclcpp
72-
rclcpp_action
73-
rclcpp_lifecycle
74-
scitos2_msgs
75-
behaviortree_cpp_v3
76-
nav2_behavior_tree
68+
target_link_libraries(scitos2_is_bumper_activated_condition_bt_node
69+
PUBLIC
70+
rclcpp::rclcpp
71+
${scitos2_msgs_TARGETS}
7772
)
78-
79-
add_library(scitos2_is_bumper_activated_condition_bt_node SHARED src/condition/is_bumper_activated_condition.cpp)
80-
list(APPEND plugin_libs scitos2_is_bumper_activated_condition_bt_node)
73+
ament_target_dependencies(scitos2_is_bumper_activated_condition_bt_node
74+
PUBLIC
75+
behaviortree_cpp_v3
76+
) # TODO(ajtudela): Fix this in jazzy
77+
target_compile_definitions(scitos2_is_bumper_activated_condition_bt_node PRIVATE BT_PLUGIN_EXPORT)
8178

8279
add_library(scitos2_emergency_stop_service_bt_node SHARED src/action/emergency_stop_service.cpp)
83-
list(APPEND plugin_libs scitos2_emergency_stop_service_bt_node)
80+
target_include_directories(scitos2_emergency_stop_service_bt_node PUBLIC
81+
"$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>"
82+
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
83+
)
84+
target_link_libraries(scitos2_emergency_stop_service_bt_node
85+
PUBLIC
86+
${scitos2_msgs_TARGETS}
87+
)
88+
ament_target_dependencies(scitos2_emergency_stop_service_bt_node
89+
PUBLIC
90+
nav2_behavior_tree
91+
) # TODO(ajtudela): Fix this in jazzy
92+
target_compile_definitions(scitos2_emergency_stop_service_bt_node PRIVATE BT_PLUGIN_EXPORT)
8493

8594
add_library(scitos2_reset_motor_stop_service_bt_node SHARED src/action/reset_motor_stop_service.cpp)
86-
list(APPEND plugin_libs scitos2_reset_motor_stop_service_bt_node)
87-
88-
foreach(bt_plugin ${plugin_libs})
89-
ament_target_dependencies(${bt_plugin} ${dependencies})
90-
target_compile_definitions(${bt_plugin} PRIVATE BT_PLUGIN_EXPORT)
91-
endforeach()
95+
target_include_directories(scitos2_reset_motor_stop_service_bt_node PUBLIC
96+
"$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>"
97+
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
98+
)
99+
target_link_libraries(scitos2_reset_motor_stop_service_bt_node
100+
PUBLIC
101+
${scitos2_msgs_TARGETS}
102+
)
103+
ament_target_dependencies(scitos2_reset_motor_stop_service_bt_node
104+
PUBLIC
105+
nav2_behavior_tree
106+
) # TODO(ajtudela): Fix this in jazzy
107+
target_compile_definitions(scitos2_reset_motor_stop_service_bt_node PRIVATE BT_PLUGIN_EXPORT)
92108

93109
# ############
94110
# # Install ##
95111
# ############
96-
install(TARGETS ${plugin_libs}
112+
install(TARGETS
113+
scitos2_is_bumper_activated_condition_bt_node
114+
scitos2_emergency_stop_service_bt_node
115+
scitos2_reset_motor_stop_service_bt_node
116+
EXPORT ${PROJECT_NAME}
97117
ARCHIVE DESTINATION lib
98118
LIBRARY DESTINATION lib
99119
RUNTIME DESTINATION bin
@@ -104,14 +124,14 @@ set(GENERATED_DIR ${CMAKE_CURRENT_BINARY_DIR}/gen)
104124
configure_file(plugins_list.hpp.in ${GENERATED_DIR}/plugins_list.hpp)
105125

106126
add_executable(generate_scitos2_tree_nodes_xml src/generate_scitos2_tree_nodes_xml.cpp)
107-
ament_target_dependencies(generate_scitos2_tree_nodes_xml ${dependencies})
127+
ament_target_dependencies(generate_scitos2_tree_nodes_xml PUBLIC behaviortree_cpp_v3) # TODO(ajtudela): Fix this in jazzy
108128

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

113133
install(DIRECTORY include/
114-
DESTINATION include/
134+
DESTINATION include/${PROJECT_NAME}
115135
)
116136

117137
install(DIRECTORY test/utils/
@@ -137,7 +157,19 @@ endif()
137157
# ##################################
138158
# # ament specific configuration ##
139159
# ##################################
140-
ament_export_include_directories(include)
141-
ament_export_libraries(${plugin_libs})
142-
ament_export_dependencies(${dependencies})
160+
ament_export_include_directories(include/${PROJECT_NAME})
161+
ament_export_libraries(
162+
scitos2_is_bumper_activated_condition_bt_node
163+
scitos2_emergency_stop_service_bt_node
164+
scitos2_reset_motor_stop_service_bt_node
165+
)
166+
ament_export_dependencies(
167+
behaviortree_cpp_v3
168+
nav2_behavior_tree
169+
rclcpp
170+
rclcpp_action
171+
rclcpp_lifecycle
172+
scitos2_msgs
173+
)
174+
ament_export_targets(${PROJECT_NAME})
143175
ament_package()

scitos2_behavior_tree/package.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
<license>Apache-2.0</license>
99
<author email="ajtudela@gmail.com">Alberto Tudela</author>
1010
<buildtool_depend>ament_cmake</buildtool_depend>
11+
<depend>behaviortree_cpp_v3</depend>
12+
<depend>nav2_behavior_tree</depend>
1113
<depend>rclcpp</depend>
1214
<depend>rclcpp_action</depend>
1315
<depend>rclcpp_lifecycle</depend>
1416
<depend>scitos2_msgs</depend>
15-
<depend>behaviortree_cpp_v3</depend>
16-
<depend>nav2_behavior_tree</depend>
1717

1818
<test_depend>ament_lint_auto</test_depend>
1919
<test_depend>ament_lint_common</test_depend>

scitos2_behavior_tree/test/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ add_subdirectory(condition)
55

66
# Test register
77
ament_add_gtest(test_register
8-
test_register.cpp
8+
test_register.cpp
9+
)
10+
target_link_libraries(test_register
11+
rclcpp::rclcpp
912
)
1013
ament_target_dependencies(test_register
11-
${dependencies}
14+
behaviortree_cpp_v3
1215
)

scitos2_behavior_tree/test/action/CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
ament_add_gtest(test_scitos2_action_emergency_stop_service
33
test_emergency_stop_service.cpp
44
)
5-
ament_target_dependencies(test_scitos2_action_emergency_stop_service
6-
${dependencies}
7-
)
85
target_link_libraries(test_scitos2_action_emergency_stop_service
96
scitos2_emergency_stop_service_bt_node
107
)
8+
ament_target_dependencies(test_scitos2_action_emergency_stop_service
9+
behaviortree_cpp_v3
10+
)
1111

1212
# Test for the reset motor stop service
1313
ament_add_gtest(test_scitos2_action_reset_motor_stop_service
1414
test_reset_motor_stop_service.cpp
1515
)
16-
ament_target_dependencies(test_scitos2_action_reset_motor_stop_service
17-
${dependencies}
18-
)
1916
target_link_libraries(test_scitos2_action_reset_motor_stop_service
2017
scitos2_reset_motor_stop_service_bt_node
18+
)
19+
ament_target_dependencies(test_scitos2_action_reset_motor_stop_service
20+
behaviortree_cpp_v3
2121
)
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
find_package(geometry_msgs REQUIRED)
2+
find_package(rclcpp_action REQUIRED)
3+
find_package(tf2_msgs REQUIRED)
4+
find_package(tf2_ros REQUIRED)
5+
16
# Test for is bumper activated condition
27
ament_add_gtest(test_scitos2_condition_is_bumper_activated
38
test_is_bumper_activated_condition.cpp
49
)
5-
ament_target_dependencies(test_scitos2_condition_is_bumper_activated
6-
${dependencies}
7-
)
810
target_link_libraries(test_scitos2_condition_is_bumper_activated
11+
${geometry_msgs_TARGETS}
912
scitos2_is_bumper_activated_condition_bt_node
13+
${scitos2_msgs_TARGETS}
14+
rclcpp_action::rclcpp_action
15+
${tf2_msgs_TARGETS}
16+
tf2_ros::tf2_ros
1017
)

scitos2_charging_dock/CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ Changelog for package scitos2_charging_dock
77
* Initial release.
88
* Create README.md.
99
* Redo the package to use the new docking system.
10+
* Update CMakeLists.txt to use modern idioms.
1011
* Contributors: Alberto Tudela

0 commit comments

Comments
 (0)