Skip to content

[ament_export_targets] Use IMPORTED_TARGETS directory property when CMake version is 3.21+ #367

Open
@sloretz

Description

@sloretz

Currently ament_export_targets(<export_name>) is given the name of the export which export targets, but it doesn't actually know what targets that export name is going to be used to export. When a package using ament_export_targets() is find_package()'d by a downstream package, it will search for matches to a regex on the generated export file to get a list of targets it exports. These targets are then added to a package_TARGETS variable. This is a little fragile as any upstream changes to CMake could break the regex matching

Example in an export file the above code matches

foreach(_expectedTarget rcutils::rcutils)

CMake 3.21 adds a directory property IMPORTED_TARGETS that would allow the info to be queried directly. If one queries IMPORTED_TARGETS before and after including the export file, then all the new imported targets can be added to package_TARGETS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions