ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Configuring a cmake library from the package.xml

asked 2022-03-29 22:14:21 -0500

catch22 gravatar image

updated 2022-03-30 16:17:51 -0500

Is there a way to put standard cmake options in the package.xml and have them passed onto a standard cmake package at configure time?

I'd like to pass in a custom "cmake_prefix_path" to a specific package but can't figure out how this might be done.

How do you typically customise standard cmake libraries when used with ROS. Do I need wrap every single library I use in a "vendor" package.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-03-30 06:22:01 -0500

gvdhoorn gravatar image

updated 2022-03-31 03:02:18 -0500

Is there a way to put standard cmake options in the package.xml and have them passed onto a standard cmake package at configure time?

No, that's not supported right now.


Edit:

How do you typically customise standard cmake libraries when used with ROS.

technically, I believe the answer would be: "you don't".

ROS does not do anything special in this area. It's all just CMake (edit: for CMake-based packages that is), and anything which didn't start out as a "ROS package" would be considered a system dependency.

Do I need wrap every single library I use in a "vendor" package.

No, that's not required at all.

Only if you want to support platforms/OS for which there is no binary release of your dependency and you want to be able to treat your has-to-be-built-from-source-dependency as your actual ROS packages (ie: plop it in a workspace, have it download the sources as part of the configure step, etc. Similar to how CMake FetchContent works). AFAIK, vendor-packages should be considered a last-resort.

If possible, I personally manage system dependencies in whatever way the OS manages them. If possible, install pre-packaged binaries. If you're building from source, how would you normally do that? If you want to automate that, how would you normally do that?

For ROS 2 specifically -- which basically means: when driving your workspace build with Colcon -- you could make use of the various ways Colcon supports specifying metadata for packages / workspaces. See #q333249 for a previous Q&A about this.

An example (from here):

{
    "name": "microcdr",
    "type": "cmake",
    "cmake-args":[
        "-DUCDR_ISOLATED_INSTALL=OFF"
    ]
}

Micro-CDR is a plain-CMake project. When the build is being driven by Colcon, it will read this colcon.pkg file and set the CMake argument included in it.

But note that this is not required for a system dependency. It's a convenient bit of functionality, but regardless of how you manage your dependencies: as long as CMake can work with / find them, your ROS 2 package should be able to as well.

edit flag offensive delete link more

Comments

Thank you for the advice.

I don't want to install these libraries into my system because they are only used by my ROS project. That is they are project dependencies not system dependencies.

The workaround I'm using with some success, based upon your comments

  1. build the libraries I need for the ROS project and install them somewhere for example $HOME/my-ros-project-dependencies

  2. export this path so cmake knows where to look when invoked from colcon, maybe I could put this in the colcon.pkg, but I haven't tried this yet export CMAKE_PREFIX_PATH=$HOME/my-ros-project-dependencies

  3. build with colon

The app run ok from the build folder.

The installed apps have issues

The rpath info is getting wiped, so the shared libs are not found. For now I can manage this by manually setting LD_LIBRARY_PATH.

catch22 gravatar image catch22  ( 2022-04-03 22:16:22 -0500 )edit

I don't want to install these libraries into my system because they are only used by my ROS project. That is they are project dependencies not system dependencies.

in "ROS parlance", everything not a ROS package is called a system dependency.

The way you've installed them seems like an acceptable -- albeit perhaps not be most easily reproducable -- approach.

gvdhoorn gravatar image gvdhoorn  ( 2022-04-04 02:23:56 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2022-03-29 22:14:21 -0500

Seen: 152 times

Last updated: Mar 31 '22