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_dependencies needs to be called before ament_export_targets #430

Open
Leon0402 opened this issue Feb 28, 2023 · 2 comments
Open
Labels

Comments

@Leon0402
Copy link

Hi,

the documentation suggests that you would do something like:

ament_export_targets(my_libraryTargets HAS_LIBRARY_TARGET)
ament_export_dependencies(some_dependency)

where ament_export_targets is called before ament_export_dependencies. There is also no mentioning if the order is relevant in any way in the docs.

In one of my projects I ran into some issues with this. Based on some experiments it seems ament_export_dependencies calls have to be placed before ament_export_targets.

The code will generate a <PackageName>Config.cmake file, which contains the following lines:

# include all config extra files
set(_extras "ament_cmake_export_dependencies-extras.cmake;ament_cmake_export_targets-extras.cmake")
foreach(_extra ${_extras})
  include("${main_DIR}/${_extra}")
endforeach()

It is important that ament_cmake_export_dependencies-extras.cmake will be processed before ament_cmake_export_targets-extras.cmake, because the first one defined dependencies of the target.
If you switch the order of the commands as seen in the documentation, the order in this snipped is reversed as well and will lead to an error.

If necessary I might be able to post a reproducible example.

If I am correct with my assumption, I suggest that the documentation is updated for now to reflect the correct order and have some note about this behaviour. In the long run it would obviously better if the order would not matter and ament just always puts dependencies in the Config.cmake file first.

@clalancette
Copy link
Contributor

If necessary I might be able to post a reproducible example.

If you could post this, that would be helpful. We aren't totally sure what we can do about it, but it would definitely help to have the example.

@roncapat
Copy link

I had troubles building from sources PicknikRobotics/RSL package from source with cmake 2.26 on ubuntu 20.04. Switching ament_export_dependencies and ament_export_targets solved the issue for me. May be related (but I don't have more time for digging here, not a cmake expert).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants