Ask Your Question
0

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
0

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

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

Seen: 26 times

Last updated: Jul 16