Using Conan in ROS2 Package

Hi everyone!
I used conan to manipulate dependencies in ros2 package developmen, but I ran in some troubles:

  1. Header files. Suppose I use conan package (such as glog, gflags) in A package, and B depends on A, then awful thing happens, I can’t acquire those conan packages’s header files path in B.
  2. Libraries. Like above, I have to source activated_run.sh in A before building B package.
    Is there solution in ament_cmake to solve these?
3 Likes

Any insights to this problem?

Hi!

The way to propagate headers of Conan generated CMake targets is using the ament helper ament_target_dependencies(). That way, the Conan packages are treated as a ROS package target and linked in the same way:

ament_target_dependencies(${TARGET_NAME} rclcpp <conan-require-name>)

We have recently released a new integration for using Conan packages in ROS, so you’d like to check it out (it talks about the management of Conan packages as transitive dependencies as well): Enhancing ROS robotics development with C/C++ Conan packages

1 Like

Hmm, without a package.xml in the conan dependencies, how do you prevent rosdep from installing (or at least trying to) the system apt packages? How do you intend to let rosdep know this dependency is handled by conan?

1 Like

This is interesting, thanks for sharing!

From what I understand, ROS 2 packages are still managed via apt, so how do you ensure that there are no ABI conflicts from packages that are installed from apt as dependencies of ROS 2 packages, and packages that are installed by conan, as fmt in the example, that if I recall correctly is also a ROS transitive dependency via spdlog?

1 Like

yes, that’s true.

The aim of the integration is to provide the ROS developers with an alternative and to be able to consume the conan packages easily. Of course, there could be conflicts or redundant dependencies between rosdep and conan, however, we do not envision conan as replacement of rosdep/apt, but as a complement to incorporate new libraries to ROS packages in an easy workflow.

we did some tests with rosdep writing a Conan component to let rosdep install Conan packages and it worked well with some small caveats but it could be done as a complement to the ROSEnv generator.

However, first, we had to add the ROSEnv generator as a way to activate the build environment for Colcon to recognize the Conan installed dependencies.

If the rosdep integration part is something that could be useful please let us know, we are willing to streamline the integration for ROS users. Thank you!

1 Like

I think this would help, ROS 2 Conan Integration - Next Generation ROS - ROS Discourse