Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sloretz opened this issue Dec 6, 2021 · 3 comments
Labels
backlog enhancement New feature or request

Comments

@sloretz
Copy link
Contributor

sloretz commented Dec 6, 2021

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.

@topin89
Copy link

topin89 commented Aug 8, 2022

This is a little fragile as any upstream changes to CMake could break the regex matching

Yup, a cat knocked the code off a table about 4 days ago

@fake-name
Copy link

This caused multiple of my colleagues to waste several hours with mysterious build errors today, and I just spent several hours getting to the point where I (finally) found this issue.

If this was a known-going-to-break, at least fail on cmake >= 3.24, rather then wasting so much time.

@topin89
Copy link

topin89 commented Aug 9, 2022

If this was a known-going-to-break, at least fail on cmake >= 3.24, rather then wasting so much time.

Well, it was broken for only four days, and fix is on its way. It may took longer for LTS releases, of course.

Wait, fix is being here for four days as well. Now I'm not sure how long it will be before it's merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants