Is ament_auto_add_library() recommended or not?

Hi,

I see some project uses ament_auto_add_library extensively, but when I tried to lookup the document of ament_auto_add_library, I can barely find any.

At the document of ament_cmake, ament_cmake user documentation — ROS 2 Documentation: Jazzy documentation, ament_auto_add_library is actually not mentioned, instead, it says to use add_library to create a library project.

So I’d like to check what is the recommended way to use ament_cmake to create a project (library or executable).

Thanks.

It’s from the ament_cmake_auto library.

It’s available but not that well documented.
It can simplify your CMakeLists.txt, especially in simple cases.

About what the recommended way is, I’m not sure.
The best thing is to choose the correct tool for the job, which also depends on preference.

Personally, I prefer it over only using ament_cmake, because of the convience in regards to dependencies and file installation.

In my experience, I’ve found my life becomes easier the less ament macros I use.

The only ones that I feel are necessary are things like ament_package() and some of the testing macros, which allow for discoverability with things like rosdep , ament_package_index, and/or colcon build / test.

7 Likes

I have the same feeling and that’s why I asked.

In ros2 kilted Kaiju version, ament_target_dependencies is deprecated, I’m not sure if more ament_* will be deprecated, what’s the longtime plan form ament_cmake.