0
$\begingroup$

Rosanswers logo

I am trying to using add_custom_target to invoke a binary during the build process. This is tricky because the binary is built by another Catkin package and is installed its libexec directory. I can't figure out how to make this work when both packages are built in the same Catkin workspace. I also am not sure how to call the binary in a way that is portable between the devel and install spaces.

These seem to be two separate issues:

  1. How do make my custom target depend on the binary built by the other package? I can't simply add it as a dependency, because that would fail when the other package is in a chained workspace.
  2. What is the correct way of resolving the path to the binary? Should I use rosrun, rospack, or catkin_find? Or do I need to somehow export a CMake variable that contains the path?

Originally posted by mkoval on ROS Answers with karma: 524 on 2014-06-15

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I found a few other answers that hint at the solution. This is what I finally came up with that works:

I created a file my_package-extras.cmake.em that exports CMake variables that point to all of the binary files that I plan to use during the build of another Catkin project. This file detects whether we are doing a devel build or an install build---and sets the paths appropriately---by checking whether my_package_SOURCE_DIR is defined.

Finally, I added the option CFG_EXTRAS my_package-extras.cmake to the catkin_package() call. This file will be included in any CMake files that find_package(my_package). Therefore, those CMake files can use the variables defined in that file to depend on (to insure that its built) and call the binaries exported by my_package.


Originally posted by mkoval with karma: 524 on 2014-06-19

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

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