Use unique name for exported targets and avoid exporting binary targets #396
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug fix
Fixed bug
The libraries in
rmf_ros2
cannot be linked to by usingament_target_dependencies
, forcing downstream users to usetarget_link_libraries
instead.Fix applied
Based on the guidelines in the ament_cmake docs, specifically the sample library:
The exported target has a unique name rather than the library name, this is also explicitly suggested in a later paragraph that says the following:
The EXPORT notation of the install call requires additional attention: It installs the CMake files for the my_library target. It must be named exactly the same as the argument in ament_export_targets. To ensure that it can be used via ament_target_dependencies, it should not be named exactly the same as the library name, but instead should have a prefix like export_ (as shown above).
Furthermore, we were exporting binaries and targets and downstream users using
ament_target_dependencies
would get cryptic CMake failures such as:So I split the installation step to make sure we only export targets for the library and not for the executable, again following the documentation.
These changes made it possible to compile downstream applications that link to
rmf_fleet_adapter
(I haven't tested the other packages but applied the same fix for consistency)