Ask Your Question

What dependencies to specify in CMakeLists.txt and which to specify in package.xml?

asked 2017-04-27 08:58:09 -0600

nbro gravatar image

updated 2017-04-27 16:05:06 -0600

Even after having read this post regarding the difference between CMakeLists.xml and package.xml files (in the ROS context), I'm still not sure which dependencies should be specified in one or the other file.

I thought I needed to include (at least) in find_package (of the CMakeLists.xml) all the build dependencies (what about the other dependencies?) specified in the corresponding package.xml file, but this isn't the case, since I have a package where I'm specifying rospkg as a <build_depend> in package.xml, but if I also include rospkg in find_packages it gives me an error of the form

Could not find a package configuration file provided by "rospkg" with any of the following names:


On the other hand, a package like rospy also contains C++ code and I can include it in the find_package list.

The reason to have a package.xml and also a CMakeLists.txt is mainly due to, I guess, the need to support Python and C++ in ROS, but it's not very clear, again, which dependencies need to be specified in which files.

I checked the Github repository for rospkg and, indeed, it does not contain any C++ files (if I checked correctly), and thus it wouldn't make much sense to include rospkg in CMakeLists.xml...

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-04-27 17:40:39 -0600

ahendrix gravatar image

You should specify ALL of your dependencies in the package.xml, since this is used to determine which packages are needed to build and run your package.

Since the CMakeLists.txt is used to build your messages and C++ code, you only need to specify your message and C++ dependencies in your CMakeLists.txt.

If you're writing python code, you should also write a where you specify your python package name and python dependencies.

edit flag offensive delete link more


But by C++ dependencies do you mean all non-catkin (external) dependencies, or do you also mean catkin packages which contain C++ code (and thus I would need to check which catkin packages have C++ code)?

nbro gravatar image nbro  ( 2017-04-27 18:39:50 -0600 )edit

By C++ dependencies, I mean any packages whose headers you #include in your code.

ahendrix gravatar image ahendrix  ( 2017-04-27 18:41:54 -0600 )edit

So, basically, also catkin packages which contain C++ code which I need to include.

nbro gravatar image nbro  ( 2017-04-27 18:45:59 -0600 )edit

You say I should specify Python dependencies in the file. I read around that file isn't used as for a general Python package, but just by catkin. Is this true? By Python dependencies do you mean also catkin packages or just external Python dependencies?

nbro gravatar image nbro  ( 2017-04-27 18:46:53 -0600 )edit

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: 2017-04-27 08:58:09 -0600

Seen: 477 times

Last updated: Apr 27 '17