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

When to use the dependency EXPORTED_TARGETS vs generate_messages_cpp

asked 2023-01-04 20:01:07 -0500

kacaroll gravatar image

updated 2023-01-04 20:01:50 -0500

Let's suppose pkg1 creates new services, messages, and actions. If I want a cpp ROS node from within this pkg1 to ensure that the messages, services, and actions are all built before the cpp file is built, would I add: add_dependencies(cpp_file_target pkg1_EXPORTED_TARGETS) or add_dependencies(cpp_file_target pkg1_generate_messages_cpp)? Really, what's the difference in this case?

Additionally, if pkg2 wanted to use messages from pkg1, and find_package() included pkg1, would a dependency on ${catkin_EXPORTED_TARGETS} be sufficient? Or would pkg2 need to depend on pkg1_generate_messages_cpp?

I wasn't able to find a clear answer within the documentation and would appreciate guidance for best practices.

edit retag flag offensive close merge delete

Comments

1

I seem to remember this has been discussed before. See #q286311, #q201227 and #q52744 for instance. The second Q&A links to relevant documentation. The third Q&A's accepted answer has a bunch of comments which go into some more detail, and the second answer is the preferred way of doing things "nowadays" (note: the third Q&A is from 2013).

If you could read those (and perhaps find some additional info, use Google, append site:answers.ros.org to your query), and things are still unclear, please update your question and explain what is unclear exactly.

Let's try to avoid duplicating discussions.

gvdhoorn gravatar image gvdhoorn  ( 2023-01-05 06:28:01 -0500 )edit

Thanks for the tip. This additional discussion along with your links answered my question:

kacaroll gravatar image kacaroll  ( 2023-01-05 11:31:23 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2023-01-05 11:34:21 -0500

kacaroll gravatar image

updated 2023-01-06 16:13:14 -0500

After being pointed to the right links, found out that it is best practice to always use catkin_EXPORTED_TARGETS for any pkg that depends on any ROS message, service, etc... pkg1_EXPORTED_TARGETS is only required if pkg1 creates new messages, actions, headers, etc.. (non libs) pkg1_generate_messages_cpp is a subset of pkg1_EXPORTED_TARGETS catkin_EXPORTED_TARGETS does NOT include messages, actions, headers, etc... from the current project

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-01-04 20:01:07 -0500

Seen: 122 times

Last updated: Jan 06 '23