Description
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
.