[Discourse.ros.org] [Next Generation ROS] Ament best practice for sharing libraries

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Discourse.ros.org] [Next Generation ROS] Ament best practice for sharing libraries

Thilo Zimmermann via ros-users


What's the recommended best practice for exporting a library from a package for use in another package?

My specific use case is exporting composable nodes as a shared libraries from some packages and using those in another package that does link-time composition, but I imagine this is going to be a common use case.

>From poking around in the `rclcpp` `CMakeLists.txt`, this is what I've come up with. I'm not 100% sure about the purpose of the `ament_export_dependencies` lines, and I'm also assuming that I still need to manually install include files just like libraries since this seems the logical thing.

```
ament_export_dependencies(ament_cmake)
ament_export_dependencies(rclcpp)
ament_export_dependencies(class_loader)

ament_export_include_directories(include)

ament_export_libraries(displayer_component)
```

It works, but is it correct?





---
[Visit Topic](https://discourse.ros.org/t/ament-best-practice-for-sharing-libraries/3602/1) or reply to this email to respond.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>
Reply | Threaded
Open this post in threaded view
|

[Discourse.ros.org] [Next Generation ROS] Ament best practice for sharing libraries

Thilo Zimmermann via ros-users


Yes, this will work. `ament_export_libraries(...)` is basically the equivalent to `catkin_package(LIBRARIES ...)`.

A "better" / more modern way would be to generate a CMake file containing code to import the actual targets in downstream packages. This needs to steps:
* install the generated file ([example](https://github.com/ament/ament_index/blob/1df2aef4d7f1271d80082cc01aa08e13bfc58fce/ament_index_cpp/CMakeLists.txt#L51))
* export the generated file ([example](https://github.com/ament/ament_index/blob/1df2aef4d7f1271d80082cc01aa08e13bfc58fce/ament_index_cpp/CMakeLists.txt#L30))

The usage downstream is than also different: see [example](https://github.com/ros2/demos/blob/23b3bb5807223673cfd3f5e5652e8b0fe2568d7d/composition/CMakeLists.txt#L120).

We only do this in very few cases yet but the goal is to use this approach in all packages.





---
[Visit Topic](https://discourse.ros.org/t/ament-best-practice-for-sharing-libraries/3602/2) or reply to this email to respond.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>