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

catkin: dependency on package that generates headers

asked 2020-01-19 10:44:31 -0600

knxa gravatar image

updated 2020-01-20 00:53:10 -0600

  • I have a package A that generates some c++ header files and some python code.
    • I have a package B that depends on the header files from A.

I have problems creating good CMakeLists.txt that ensures that the headers in A always are built before building B.

I realize this is very much like the message generation concept, where packages can rely on messages from another package being built ahead of time.

Can I create the CMakeLists.txt for package A in such a way that a certain custom command always is ensured to run before targets from package B are being built?

edit retag flag offensive close merge delete

Comments

This seems like a general CMake question, not necessarily Catkin related (inter-target dependency declaration is a bit of CMake functionality).

Is

I realize this is very much like the message generation concept

the reason you post it here?

gvdhoorn gravatar image gvdhoorn  ( 2020-01-20 02:21:06 -0600 )edit

I had the impression that inter-package dependency was where catkin shines. And I found it likely that the solution would use a concept similar to the message generation concept. Also I wondered if the solution could relate to catkin_EXPORTED_TARGETS. I apologize if this is a misunderstanding.

knxa gravatar image knxa  ( 2020-01-20 06:01:26 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-01-22 11:36:53 -0600

Dirk Thomas gravatar image

The problem only arises with catkin_make which builds all packages in a single CMake context.

The package A needs to add the target(s) which generate the files to the following variable which will be exported through the CMake config file of the package:

list(APPEND ${PROJECT_NAME}_EXPORTED_TARGETS <your-target-name(s)-here>)

And package B needs to add a proper target dependency onto the value of the exported variable for all target which need the generated files:

add_dependency(<your-library-or-executable-target> ${a_exported_targets})

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-01-19 10:44:31 -0600

Seen: 259 times

Last updated: Jan 22 '20