Skip to content

Modernize CMakeLists.txt to remove deprecated ament_target_dependencies (Fixes #2210) #2210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions controller_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ target_include_directories(controller_interface PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/controller_interface>
)
ament_target_dependencies(controller_interface PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})
target_link_libraries(controller_interface PUBLIC
hardware_interface::hardware_interface
rclcpp_lifecycle::rclcpp_lifecycle
realtime_tools::realtime_tools
)

if(BUILD_TESTING)
find_package(ament_cmake_gmock REQUIRED)
Expand Down Expand Up @@ -70,17 +74,17 @@ if(BUILD_TESTING)
controller_interface
hardware_interface::hardware_interface
)
ament_target_dependencies(test_imu_sensor
sensor_msgs
target_link_libraries(test_imu_sensor
${sensor_msgs_TARGETS}
)

ament_add_gmock(test_pose_sensor test/test_pose_sensor.cpp)
target_link_libraries(test_pose_sensor
controller_interface
hardware_interface::hardware_interface
)
ament_target_dependencies(test_pose_sensor
geometry_msgs
target_link_libraries(test_pose_sensor
${geometry_msgs_TARGETS}
)
ament_add_gmock(test_gps_sensor test/test_gps_sensor.cpp)
target_link_libraries(test_gps_sensor
Expand All @@ -103,8 +107,8 @@ if(BUILD_TESTING)
controller_interface
hardware_interface::hardware_interface
)
ament_target_dependencies(test_led_rgb_device
std_msgs
target_link_libraries(test_led_rgb_device
${std_msgs_TARGETS}
)
endif()

Expand Down
23 changes: 18 additions & 5 deletions controller_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ find_package(backward_ros REQUIRED)
foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS})
find_package(${Dependency} REQUIRED)
endforeach()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add this link back?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

generate_parameter_library(controller_manager_parameters
src/controller_manager_parameters.yaml
)
Expand All @@ -41,8 +40,16 @@ target_include_directories(controller_manager PUBLIC
)
target_link_libraries(controller_manager PUBLIC
controller_manager_parameters
controller_interface::controller_interface
controller_manager_msgs::controller_manager_msgs
diagnostic_updater::diagnostic_updater
hardware_interface::hardware_interface
pluginlib::pluginlib
rclcpp::rclcpp
realtime_tools::realtime_tools
std_msgs::std_msgs
libstatistics_collector::libstatistics_collector
)
ament_target_dependencies(controller_manager PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})

add_executable(ros2_control_node src/ros2_control_node.cpp)
target_link_libraries(ros2_control_node PRIVATE
Expand All @@ -57,7 +64,10 @@ if(BUILD_TESTING)
# Plugin Libraries that are built and installed for use in testing
add_library(test_controller SHARED test/test_controller/test_controller.cpp)
target_link_libraries(test_controller PUBLIC controller_manager)
ament_target_dependencies(test_controller PUBLIC example_interfaces)
ament_target_dependencies(test_controller
PUBLIC
${example_interfaces_TARGETS}
)
pluginlib_export_plugin_description_file(controller_interface test/test_controller/test_controller.xml)
install(
TARGETS test_controller
Expand All @@ -78,8 +88,11 @@ if(BUILD_TESTING)
add_library(test_chainable_controller SHARED
test/test_chainable_controller/test_chainable_controller.cpp
)
ament_target_dependencies(test_chainable_controller PUBLIC realtime_tools)
target_link_libraries(test_chainable_controller PUBLIC controller_manager)
target_link_libraries(test_chainable_controller
PUBLIC
controller_manager
realtime_tools::realtime_tools
)
pluginlib_export_plugin_description_file(
controller_interface test/test_chainable_controller/test_chainable_controller.xml)
install(
Expand Down
75 changes: 48 additions & 27 deletions hardware_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(hardware_interface LANGUAGES CXX)

find_package(ament_cmake REQUIRED)
find_package(ament_cmake_gen_version_h REQUIRED)
find_package(backward_ros REQUIRED)
find_package(ros2_control_cmake REQUIRED)
set_compiler_options()
export_windows_symbols()
Expand All @@ -20,9 +23,6 @@ set(THIS_PACKAGE_INCLUDE_DEPENDS
pal_statistics
)

find_package(ament_cmake REQUIRED)
find_package(ament_cmake_gen_version_h REQUIRED)
find_package(backward_ros REQUIRED)
foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS})
find_package(${Dependency} REQUIRED)
endforeach()
Expand All @@ -40,8 +40,20 @@ target_include_directories(hardware_interface PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/hardware_interface>
)
ament_target_dependencies(hardware_interface PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})

target_link_libraries(hardware_interface PUBLIC
{control_msgs_TARGETS}
{lifecycle_msgs_TARGETS}
pluginlib::pluginlib
rclcpp_lifecycle::rclcpp_lifecycle
rcpputils::rcpputils
rcutils::rcutils
realtime_tools::realtime_tools
TinyXML2::TinyXML2
tinyxml2_vendor::tinyxml2_vendor
joint_limits::joint_limits
urdf::urdf
pal_statistics::pal_statistics
)
add_library(mock_components SHARED
src/mock_components/generic_system.cpp
)
Expand All @@ -50,8 +62,21 @@ target_include_directories(mock_components PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/hardware_interface>
)
target_link_libraries(mock_components PUBLIC hardware_interface)
ament_target_dependencies(mock_components PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})
target_link_libraries(mock_components
PUBLIC hardware_interface
{control_msgs_TARGETS}
{lifecycle_msgs_TARGETS}
pluginlib::pluginlib
rclcpp_lifecycle::rclcpp_lifecycle
rcpputils::rcpputils
rcutils::rcutils
realtime_tools::realtime_tools
TinyXML2::TinyXML2
tinyxml2_vendor::tinyxml2_vendor
joint_limits::joint_limits
urdf::urdf
pal_statistics::pal_statistics
)

pluginlib_export_plugin_description_file(
hardware_interface mock_components_plugin_description.xml)
Expand All @@ -63,27 +88,22 @@ if(BUILD_TESTING)

ament_add_gmock(test_macros test/test_macros.cpp)
target_include_directories(test_macros PRIVATE include)
ament_target_dependencies(test_macros rcpputils)
target_link_libraries(test_macros rcpputils::rcpputils)

ament_add_gmock(test_inst_hardwares test/test_inst_hardwares.cpp)
target_link_libraries(test_inst_hardwares hardware_interface)
ament_target_dependencies(test_inst_hardwares rcpputils)
target_link_libraries(test_inst_hardwares hardware_interface rcpputils::rcpputils)

ament_add_gmock(test_joint_handle test/test_handle.cpp)
target_link_libraries(test_joint_handle hardware_interface)
ament_target_dependencies(test_joint_handle rcpputils)
target_link_libraries(test_joint_handle hardware_interface rcpputils::rcpputils)

ament_add_gmock(test_component_interfaces test/test_component_interfaces.cpp)
target_link_libraries(test_component_interfaces hardware_interface)
ament_target_dependencies(test_component_interfaces ros2_control_test_assets)
target_link_libraries(test_component_interfaces hardware_interface ros2_control_test_assets::ros2_control_test_assets)

ament_add_gmock(test_component_interfaces_custom_export test/test_component_interfaces_custom_export.cpp)
target_link_libraries(test_component_interfaces_custom_export hardware_interface)
ament_target_dependencies(test_component_interfaces_custom_export ros2_control_test_assets)

target_link_libraries(test_component_interfaces_custom_export hardware_interface ros2_control_test_assets::ros2_control_test_assets)

ament_add_gmock(test_component_parser test/test_component_parser.cpp)
target_link_libraries(test_component_parser hardware_interface)
ament_target_dependencies(test_component_parser ros2_control_test_assets)
target_link_libraries(test_component_parser hardware_interface ros2_control_test_assets::ros2_control_test_assets)

add_library(test_hardware_components SHARED
test/test_hardware_components/test_single_joint_actuator.cpp
Expand All @@ -92,9 +112,10 @@ if(BUILD_TESTING)
test/test_hardware_components/test_two_joint_system.cpp
test/test_hardware_components/test_system_with_command_modes.cpp
)
target_link_libraries(test_hardware_components hardware_interface)
ament_target_dependencies(test_hardware_components
pluginlib)
target_link_libraries(test_hardware_components
hardware_interface
pluginlib::pluginlib
)
install(TARGETS test_hardware_components
DESTINATION lib
)
Expand All @@ -104,11 +125,11 @@ if(BUILD_TESTING)

ament_add_gmock(test_generic_system test/mock_components/test_generic_system.cpp)
target_include_directories(test_generic_system PRIVATE include)
target_link_libraries(test_generic_system hardware_interface)
ament_target_dependencies(test_generic_system
pluginlib
ros2_control_test_assets
)
target_link_libraries(test_generic_system
hardware_interface
pluginlib::pluginlib
ros2_control_test_assets::ros2_control_test_assets
)
endif()

install(
Expand Down
17 changes: 13 additions & 4 deletions hardware_interface_testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ test/test_components/test_actuator.cpp
test/test_components/test_sensor.cpp
test/test_components/test_system.cpp
test/test_components/test_actuator_exclusive_interfaces.cpp)
ament_target_dependencies(test_components hardware_interface pluginlib ros2_control_test_assets)
target_link_libraries(test_components PUBLIC
hardware_interface::hardware_interface
pluginlib::pluginlib
ros2_control_test_assets::ros2_control_test_assets
)
install(TARGETS test_components
DESTINATION lib
)
Expand All @@ -36,11 +40,16 @@ if(BUILD_TESTING)
find_package(ament_cmake_gmock REQUIRED)

ament_add_gmock(test_resource_manager test/test_resource_manager.cpp)
ament_target_dependencies(test_resource_manager hardware_interface ros2_control_test_assets)
target_link_libraries(test_resource_manager PUBLIC
hardware_interface::hardware_interface
ros2_control_test_assets::ros2_control_test_assets
)

ament_add_gmock(test_resource_manager_prepare_perform_switch test/test_resource_manager_prepare_perform_switch.cpp)
ament_target_dependencies(test_resource_manager_prepare_perform_switch hardware_interface ros2_control_test_assets)

target_link_libraries(test_resource_manager_prepare_perform_switch PUBLIC
hardware_interface::hardware_interface
ros2_control_test_assets::ros2_control_test_assets
)
endif()

ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS})
Expand Down
57 changes: 37 additions & 20 deletions joint_limits/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ target_include_directories(joint_limiter_interface PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/joint_limits>
)
ament_target_dependencies(joint_limiter_interface PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})
target_link_libraries(joint_limiter_interface PUBLIC
pluginlib::pluginlib
realtime_tools::realtime_tools
rclcpp::rclcpp
rclcpp_lifecycle::rclcpp_lifecycle
trajectory_msgs::trajectory_msgs
urdf::urdf
)

add_library(joint_limits_helpers SHARED
src/joint_limits_helpers.cpp
Expand All @@ -47,8 +54,14 @@ target_include_directories(joint_limits_helpers PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/joint_limits>
)
ament_target_dependencies(joint_limits_helpers PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})

target_link_libraries(joint_limits_helpers PUBLIC
pluginlib::pluginlib
realtime_tools::realtime_tools
rclcpp::rclcpp
rclcpp_lifecycle::rclcpp_lifecycle
trajectory_msgs::trajectory_msgs
urdf::urdf
)
add_library(joint_saturation_limiter SHARED
src/joint_saturation_limiter.cpp
src/joint_range_limiter.cpp
Expand All @@ -59,9 +72,16 @@ target_include_directories(joint_saturation_limiter PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/joint_limits>
)
target_link_libraries(joint_saturation_limiter PUBLIC joint_limits_helpers)
target_link_libraries(joint_saturation_limiter PUBLIC
joint_limits_helpers
pluginlib::pluginlib
realtime_tools::realtime_tools
rclcpp::rclcpp
rclcpp_lifecycle::rclcpp_lifecycle
trajectory_msgs::trajectory_msgs
urdf::urdf
)

ament_target_dependencies(joint_saturation_limiter PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})

pluginlib_export_plugin_description_file(joint_limits joint_limiters.xml)

Expand Down Expand Up @@ -95,29 +115,26 @@ if(BUILD_TESTING)
${CMAKE_CURRENT_SOURCE_DIR}/test/joint_saturation_limiter_param.yaml
)
target_include_directories(test_joint_saturation_limiter PRIVATE include)
target_link_libraries(test_joint_saturation_limiter joint_limiter_interface)
ament_target_dependencies(
test_joint_saturation_limiter
pluginlib
rclcpp
target_link_libraries(test_joint_saturation_limiter
joint_limiter_interface
pluginlib::pluginlib
rclcpp::rclcpp
)

ament_add_gmock(test_joint_range_limiter test/test_joint_range_limiter.cpp)
target_include_directories(test_joint_range_limiter PRIVATE include)
target_link_libraries(test_joint_range_limiter joint_limiter_interface)
ament_target_dependencies(
test_joint_range_limiter
pluginlib
rclcpp
target_link_libraries(test_joint_range_limiter
joint_limiter_interface
pluginlib::pluginlib
rclcpp::rclcpp
)

ament_add_gmock(test_joint_soft_limiter test/test_joint_soft_limiter.cpp)
target_include_directories(test_joint_soft_limiter PRIVATE include)
target_link_libraries(test_joint_soft_limiter joint_limiter_interface)
ament_target_dependencies(
test_joint_soft_limiter
pluginlib
rclcpp
target_link_libraries(test_joint_soft_limiter
joint_limiter_interface
pluginlib::pluginlib
rclcpp::rclcpp
)

endif()
Expand Down