0
$\begingroup$

Rosanswers logo

Hi !

I was reading this tutorial on how to add dependencies to a package, and was wondering why one would "only" need to upgrade the package.xml and not the CMakeLists.txt, where the dependencies initially given at the creation of the package can be read, in the find_package() section?

I thought catkin_make in the ~/catkin_ws would update the CMakeLists.txt according to the package.xml content, but after trying it is doesn't react as I expected it would.

Thanks & sorry if I missed that info somewhere !


Originally posted by Blupon on ROS Answers with karma: 127 on 2017-07-12

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

There is some nuance here.

Yes, the CMakeLists.txt will need to be updated if you add system dependences to your package.xml, but only if that dependency is actually used at build time (and if it's actually C++ (or some other compiled language) we're targeting).

So if a dependency does not provide headers or libraries, or some other artefact or piece of build infrastructure (like preprocessors, code generators, etc), CMakeList.txt would probably not need to be updated.

Having said that: the example shown on the page you linked to would seem to be a case where CMakeLists.txt would need to be updated -- assuming obviously that the dependency (ie: headers, libraries) are used by any of the C++ sources that are being build.


Originally posted by gvdhoorn with karma: 86574 on 2017-07-12

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by Blupon on 2017-07-24:
for example: to add depency of a package to tf sensor_msgs std_msgs to publish a jointState (like seen on this tutorial), do I need to edit the CMakeLists.txt ? Build infrastructure is new to me ^^

Comment by gvdhoorn on 2017-07-24:
Yes. Whenever you use something 'new' in your code -- and that 'something' is not something that is local to your own pkg, you'll need to add it to your manifest and update the CMakeLists.txt.

Note that this is not ROS specific. The same would be needed in a regular CMake project.

Comment by gvdhoorn on 2017-07-24:
See also: catkin 0.7.6 documentation » How to do common tasks » Package format 2 (recommended).

$\endgroup$