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

<buildtool_depend>genmsg</buildtool_depend>

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)
project(my_pkg)

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)
DIRECTORY srv
FILES
)
generate_messages(
DEPENDENCIES
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 close merge delete

Sort by » oldest newest most voted

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.

more

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.

more