Skip to content

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

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.

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?

Copy link
Member

@bmagyar bmagyar left a comment

Choose a reason for hiding this comment

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

I'm really not happy with the deprecation of the macro...

This PR now doubles the amount of lines it touches (+127 -62) and in it's current form does not help readability or compilation time.

There is inconsistent use of ${X_targets}, {X_targets} and X::X of which allow me to say the latter looks pretty bad :D

I guess the main reason for the lines of new "code" is not using THIS_PACKAGE_INCLUDE_DEPENDS anymore. If only there was a cmake macro that allowed that...

Any suggestions?

@mergify
Copy link
Contributor

mergify bot commented May 19, 2025

This pull request is in conflict. Could you fix it @LalitNarayanYadav?

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

4 participants