Can be generated as Illecoux in the background. http://answers.ros.org/question/52744/how-to-specify-dependencies-with-foo_msgs-catkin-packages/
Say I have two catkin packages, Foo and foo_msgs, in my workspace. Here's how I currently the have them set up:
I find this if I catkin_make foo, the message isn ' t generated. Indeed, Catkin_make Foo_msgs is a no-op. Catkin_make foo_msgs_gencpp Works, however. In order to get Foo to build correctly, I must add the following line to its CMakeLists.txt:
Is this? I ' d expect that building of the package foo_msgs would automatically all its generate. Is there a way to make that happen?
It turns out I solution is correct; The Foo_msgs_gencpp Auto-target should is added as a dependency of the the Foo target. Note this there is some disagreement about whether a different solution should to supported by Catkin; Kruset started a discussion on the topic here.
Since this type of explicit dependency auto-target (_gencpp and _GENPY) are necessary for using ROS Messages/actions/servic Es in any executable, library, or script, I-it should be better documented (I found no reference to it in Catkin/mig Rating_from_rosbuild). Kruset opened a related Rosdistro issue here. Add a comment 3 answers Sort by»oldest newest most voted
Using add_dependencies (...) is by design or necessity, however to it, because we cannot know or assume that Foo ' s Targets (executables or libraries) use and therefore depend on the messages which are getting generated by FOO_MSGS.
Then just execute catkin_make with no arguments.
If you are want to build foo_msgs explicitly (not the whole workspace) then as of Pull request ros/catkin#352 your can do Catki N_make--pkg foo_msgs.
Calling Catkin_make Foo_msgs is isn't sufficient because that are instructing Catkin_make to invoke the Foo_msgs make target Which does not exist. Tkruse ' s solution simply adds a foo_msgs target which depends on the foo_msgs_generate_messages_cpp target and allowing it to Be callable and causing the foo_msgs_generate_messages_cpp target to be generated. This isn't something we do by default because packages often define targets with the same name as the project which Immediately cause a conflict.
The only reliable way to build a entire package (including all of it targets) is to go to the package ' s builds space and Invoke make [all], the which is what Catkin_make--pkg does.
I Setup A example repository here:
Https://github.com/wjwwood/catkin_dem ... Link Comments 1
Hi Williamwoodall, this is very helpful! Clearly the _gencpp dependency needs to go somewhere explicitly. List it in Foo ' s cmakelists file. In this case, if foo_msgs are already installed (so catkin are only building foo), 'll the Foo_msgs_gencpp dependency be co Rrectly resolved by Catkin? Cdellin (Feb 6 ') 1
Yes, CMake'll ignore targets which are not defined, you could add add_dependencies (Foo_node bar_does_not_exist) and it W Ill build with no warnings. Williamwoodall (Feb 6 ')
great! This is my favorite solution, since it doesn ' t introduce new targets (FOO_MSGS), and explicitly encodes the dependency bet Ween the foo (binary) target and the generated CPP messages. Cdellin (Feb 7 ')
Also, I want to stress about catkin_make arguments: (a) Sometimes it are useful to builds only particular targets (yes, Targ ETS, not packages), and (b) running Catkin_make with no arguments doesn ' t; The _gencpp target is still required to ensure targets are in the built order. Cdellin (Feb 7 ')
(a) Building specific target is already supported by ' catkin_make ', any argument without a special meaning is passed Strai Ght forward to "make", the "Catkin_make--help" for details. Dirk Thomas (Feb 7)
Link CommentsYou are should check that ' ${catkin_exported_targets} ' are set to something before passing it to ' add_dependencies (...) `. William (Aug)
https://gist.github.com/wjwwood-snippets/5979727 William (Aug)
doesn ' t The fix for this issue make this check redundant? https://github.com/ros/catkin/issues/453 Kalakris (Aug)
Ah Yes, I forgot we added that. William (Aug '2)