Rosanswers logo

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?

Originally posted by 130s on ROS Answers with karma: 10937 on 2012-11-26

Post score: 1


2 Answers 2


Rosanswers logo

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.

Originally posted by Lorenz with karma: 22731 on 2012-11-26

This answer was ACCEPTED on the original site

Post score: 2


Rosanswers logo

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.

Originally posted by KruseT with karma: 7848 on 2012-11-26

This answer was NOT ACCEPTED on the original site

Post score: 3


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.