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

Advantage of linking to genmsg in CMakeLists.txt / package.xml?

asked 2012-11-26 10:08:06 -0600

130s gravatar image

updated 2014-01-28 17:14:23 -0600

ngrennan gravatar image

As of now (Nov 26 '12), rospy_tutorials/Tutorials/Makefile page states for package.xml:


This line will have no effect when genmsg exists ouside your workspace, since genmsg is already installed. But for people using your package in the same workspace as genmsg will benefit from this line.

In my current particular case, I'm using genmsg that resides under /opt/ros/groovy/share/ so it makes sense if I'm not taking any advantage.

Also for CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)

find_package(catkin REQUIRED COMPONENTS rospy genmsg)

Without declaring both of above for genmsg, I'm able to generate srv binding files (in python as I want) by commenting in 2 macros in CMakeLists.txt as following:

find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs)
  std_msgs  # Or other packages containing msgs

(I'm working on this tutorial).

Question is that is there any advantage of declaring genmsg in either/both package.xml & CMakeLists.txt as above?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-11-26 21:07:31 -0600

Lorenz gravatar image

According to the text you posted, I would say yes, there is an advantage. If you or a user of your package boostrap ROS completely from source which means they have rosmsg in their workspace, it will only work if you add the dependency in the package.xml and CMakeLists.txt file. I would consider adding all required dependencies for all possible cases good practice.

edit flag offensive delete link more

answered 2012-11-26 22:35:53 -0600

KruseT gravatar image

What Lorenz says is right, to answer in a different way: It is always a bug to not declare a dependency, even if on your system, it is not needed. A package should be compilable on all systems, not just your system.

The reason why you do not need the dependency in your CMakeLists,txt is because catkin merges all workspace projects into one. so if one project inyour workspace calls find_package(genmsg), all workspace projects (configured after this project), will also have access to genmsg.

Some may consider this a design flaw in catkin, because people may forget to declare such dependencies because of that.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2012-11-26 10:08:06 -0600

Seen: 739 times

Last updated: Nov 26 '12