-
Notifications
You must be signed in to change notification settings - Fork 127
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
add support for COMPONENTS in ament_export_dependencies
#456
Comments
Could we try something like this using the taret property I have a massive library with 40+ dependencies, some are brought in with generator expressions depending on what the operating system compilation options specify. I can't blindly export all dependencies that are possible with ament_export_dependencies, and it's not feasible for me to manually maintain the exact ordering of them due to the complex chaining. find_package(rclcpp REQUIRED)
find_package(my_private_algs REQUIRED)
# And other deps
add_library(${PROJECT_NAME} ...)
target_link_libraries(${PROJECT_NAME} PUBLIC rclcpp::rclcpp PRIVATE my_private_algs::my_private_alg1 my_private_algs::my_private_alg2)
install(
TARGETS ${CMAKE_PROJECT_NAME}
EXPORT export_${CMAKE_PROJECT_NAME}
)
ament_export_targets(export_${CMAKE_PROJECT_NAME} HAS_LIBRARY_TARGET)
get_target_property(${CMAKE_PROJECT_NAME}_link_libs ${CMAKE_PROJECT_NAME} LINK_LIBRARIES)
ament_export_dependencies(
${CMAKE_PROJECT_NAME}_link_libs
) Have you considered how you handle dependencies relying on each other? IE: |
@Ryanf55 correct me if I am wrong, but I am not sure the
I couldn't find this information in the documentation. Where did you find it? In particular, it is normally not a problem to find the same package multiple times but with different components. For example, these two should behave the same: # multiple
find_package(PCL REQUIRED COMPONENTS common)
find_package(PCL REQUIRED COMPONETNS io)
# single
find_package(PCL REQUIRED COMPONENTS common io) So there should be no problem if several dependencies are using different components of the same library. If there is an issue, it is up to the upstream library to fix it, not ament. |
I have meet the same issue, and I have read many sites to handle the issue, the funniest thing is that the ealiest issue I've found is proposed in 2019. in this years, developments could only handle this situation were used the hardest way: create a file.Please accept this PR as fast as you can. |
Yea, I found the |
As a follow up of old closed issues:
Problem
Let's consider the following example:
common
andio
components, and on Boostthread
On Package A, we would have something like:
On package B, we would have:
As reported in other issues, this does not work. Essentially, what
ament_export_dependencies(PCL Boost)
does is to add afind_package(PCL)
andfind_package(Boost)
in downstream packages.find_package(PCL)
includes all PCL components, so "it will work", even though it will also bloat downstream packages with useless PCL components. On the other hand,find_package(Boost)
does not include thethread
component, and the downstream package will be broken.The alternative is not to use
ament_export_dependencies()
in packageA and instead fetch PCL and Boost components manually downstream, in such case package B would look like this:Although this works and does exactly what is required, it makes no sense for downstream packages to have to fetch upstream dependency themselves.
Solution
The solution is to let the user export components. Previous issues have suggested a new
ament_export_dependency_with_components()
macro, but I think the functionality can be added to the existingament_export_dependencies()
macro.For example:
Example implementation
Current implementation accepts syntax
ament_export_dependencies(depA depB depC...)
. The macro call appends all these dependencies to_AMENT_CMAKE_EXPORT_DEPENDENCIES
(e.g."prevDepX;depA;depB;depC"
). Later, when the package B callsfind_package(PackageA)
,find_package()
is called on each listed dependency.There could be a new syntax
ament_export_dependencies(depA COMPONENTS compA compB...)
. WhenCOMPONENTS
keyword is used, the dependency components would be packed and appended to_AMENT_CMAKE_EXPORT_DEPENDENCIES
using a special separator character (e.g.:
). For example:prevDepX;depA:compA:compB
. Then, when someone callsfind_package(PackageA)
, the list of components would be unpacked into afind_package(depA QUIET REQUIRED COMPONENTS compA compB)
.Note that when the
COMPONENTS
keyword is used, only 1 dependency would be allowed per call. The 2 syntaxes would remain valid:The text was updated successfully, but these errors were encountered: