ament / ament/ament_cmake

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

Aperta
#367 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
backlog enhancement
Lingua principale
CMake
Stelle
125
Fork
147
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Currently `ament_export_targets()` 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

https://github.com/ament/ament_cmake/blob/efcbe328d001c9ade93a06bd8035642e37dd6f2a/ament_cmake_export_targets/cmake/ament_cmake_export_targets-extras.cmake.in#L12

Example in an export file the above code matches

```CMake
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`.

https://github.com/ament/ament_cmake/blob/efcbe328d001c9ade93a06bd8035642e37dd6f2a/ament_cmake_export_targets/cmake/ament_cmake_export_targets-extras.cmake.in#L12

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.