0
$\begingroup$

Rosanswers logo

  • 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?


Originally posted by knxa on ROS Answers with karma: 811 on 2020-01-19

Post score: 0


Original comments

Comment by gvdhoorn on 2020-01-20:
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?

Comment by knxa on 2020-01-20:
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.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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})


Originally posted by Dirk Thomas with karma: 16276 on 2020-01-22

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.