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

add_dependencies(listener beginner_tutorials_generate_messages_cpp) explanation

asked 2019-07-14 04:08:19 -0500

Ananda gravatar image

updated 2019-07-15 02:13:43 -0500

I am currently doing the ROS tutorial on Writing a Simple Publisher and Subscriber (C++). I do not understand the explanation for including this line add_dependencies(talker beginner_tutorials_generate_messages_cpp) in the package CMakeLists.txt file. Here is the accompanying explanation of the line:

Note that you have to add dependencies for the executable targets to message generation targets:

add_dependencies(talker beginner_tutorials_generate_messages_cpp)

This makes sure message headers of this package are generated before being used. If you use messages from other packages inside your catkin workspace, you need to add dependencies to their respective generation targets as well, because catkin builds all projects in parallel.

What is headers of the package used by? What is beginner_tutorials_generate_messages_cpp? Is it the message generation target? What is a message generation target?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-07-15 02:53:04 -0500

pavel92 gravatar image

updated 2019-07-16 02:00:28 -0500

You can read this for more information about CMakeLists (section 8).
Here is a related question about the differtence between "_generate_messages_cpp" and "_exported_targets". This one gives also some info on _generate_messages_cpp.

The difference of catkin and project exported targets (not only messages) is well explained in this answer.

Basically, beginner_tutorials_generate_messages_cpp means that the messages should be build before the target since the target is using them. If you have a package which builds messages and executable that use them, then you need to create an explicit dependency on the automatically generated message target so that they are built in the correct order.

edit flag offensive delete link more

Question Tools


Asked: 2019-07-14 04:08:19 -0500

Seen: 1,401 times

Last updated: Jul 16 '19