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

Conversation

LalitNarayanYadav
Copy link

@LalitNarayanYadav LalitNarayanYadav commented Apr 29, 2025

Modernize CMakeLists to remove ament_target_dependencies() deprecation warnings

This PR updates the CMakeLists.txt file to replace deprecated ament_target_dependencies() calls with modern target_link_libraries() using namespaced targets, as recommended by ROS 2 on Rolling.

✅ Changes

  • Replaced all ament_target_dependencies() usages with target_link_libraries() and appropriate namespaced targets.
  • Ensured compatibility with ROS 2 Rolling while preserving functionality.

📦 Benefits

  • Eliminates CMake deprecation warnings
  • Aligns with modern CMake best practices
  • Future-proofs the build system

Closes #2207

Copy link
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

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

@LalitNarayanYadav Thank you for your comments. Just some minor comments, if they look good, you can commit them directly from UI

Comment on lines 9 to 19

find_package(controller_interface REQUIRED)
find_package(controller_manager_msgs REQUIRED)
find_package(diagnostic_updater REQUIRED)
find_package(hardware_interface REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(realtime_tools REQUIRED)
find_package(std_msgs REQUIRED)
find_package(libstatistics_collector REQUIRED)
find_package(generate_parameter_library REQUIRED)
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason for this change?

Copy link
Author

@LalitNarayanYadav LalitNarayanYadav left a comment

Choose a reason for hiding this comment

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

Please review the changes.

@@ -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

Co-authored-by: Sai Kishor Kothakota <[email protected]>
@saikishor
Copy link
Member

@LalitNarayanYadav Please fix the failing CI jobs. Please try to install pre-commit and fix by running the pre-commit run --all--files and also build it locally and then push it please

@bmagyar
Copy link
Member

bmagyar commented Apr 30, 2025

It would also be good to give the PR a meaningful title.

@LalitNarayanYadav hope you don't mind me asking but how much of the original content of this PR was AI generated?

@LalitNarayanYadav LalitNarayanYadav changed the title Fix Modernize CMakeLists.txt to remove deprecated ament_target_dependencies (Fixes #2210) Apr 30, 2025
@bmagyar
Copy link
Member

bmagyar commented Apr 30, 2025

☝️ @LalitNarayanYadav did this build for you locally?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modernize CMakeLists
3 participants