Ask Your Question

conditional <exec_depend> in package.xml

asked 2020-07-28 06:33:24 -0600

broomstick gravatar image

updated 2020-07-28 06:38:35 -0600

I am writing some tests for a research version of FreeBSD. In certain configurations, I have an available library against which I want to build. In other configurations, the library doesn't exist and I need to avoid any dependency on it.

I would like to do this by making the library a conditional dependency based on an argument passed to cmake (via colcon). E.g., if I use --cmake-args -DHAS_LIBRARY=1 then it builds against the library, but otherwise ignores it.

This is fairly straightforward in my CMakeList.txt file, since I can just wrap find_package and ament_target_dependencies in conditional statements.

I don't know how to do this in the package.xml file. Further, I expect this isn't really possible and I'm going about this the wrong way entirely...

What I'd LIKE to do is wrap my <exec_depend>conditional_library_package</exec_depend> statement in a conditional (I recognise I'm mixing and matching semantics here, but it seemed the easiest way to explain what I'm hoping to do).

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-07-28 08:46:42 -0600

mgruhler gravatar image

This is not possible. If by "writing tests" you mean this is something you only need for tests, a test_depend and an implementation of this feature request could help.

However, as where we are today, I think your out of luck.

If the behavior is similar to ROS1, though, you could just omit to declare the dependency in the package.xml. This would still allow to compile the package the way you do. However, this obviously renders rosdep more or less useless, at least for that specific library package. You would need to manually ensure that the library package is installed, if you want to use it. And obviously, any releases via the ROS buildfarm will only work for the version without that package...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2020-07-28 06:33:24 -0600

Seen: 258 times

Last updated: Jul 28 '20