Skip to content

Consider updating to ament_export_targets (Modern CMake) #751

@Ryanf55

Description

@Ryanf55

Current Behavior

BehaviorTree.CPP has support for ament (YAY!), but it's using the old-style macros that were for before CMake 3, in that they set variables instead of target properties. They may be deprecated soon: ament/ament_cmake#365

Desired Behavior

When you call find_package in the ROS ecosystem, it's becoming more common practice to use target_link_libraries and link to an exported namespaced target. This is not yet possible.

  • Update this section of ament_build.cmake to :
    • Remove the line with ament_export_include_directories
    • Remove the line with ament_export_libraries
    • Add a call to ament_export_targets
  • Update documentation on recommended usage with target_link_libraries as an alternative to ament_target_dependencies, perhaps by appending a "Usage with CMake" Guide somewhere to the docs
  • Add a CI task that verifies the changes to the ROS build don't break consumers
  • Patch this into a release, and release binaries for rolling, iron and humble, since it is backward compatible.

Why? Productivity! If you spell behaviortree-cpp wrong when you call target_link_libraries, you get include errors instead of a nice "This target doesn't exist error". Exported namespace targets catch bugs at configure time rather than build time.

Outside help

I can do all the work up to the release part, but do not plan to do it until you approve these changes. Please let me know if you agree with the approach presented, and I will get started.

Reference

https://docs.ros.org/en/humble/How-To-Guides/Ament-CMake-Documentation.html#installing

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions