Ask Your Question

Revision history [back]

You can do this with an extras-file (which is essentially a snippet of CMake) and exporting the location to it in your catkin_package(.. CFG_EXTRAS ..) call in the CMakeLists.txt of the package from which you'd like to export this.

See #q173947 for a Q&A where this is done for exporting compiler flags from a package, and #q93266 for an example where this is used to export a non-standard include path.

You should be able to append to CMAKE_MODULE_PATH in the same way, as the extras-file contains just regular CMake. Be sure to specify the correct path to CMAKE_MODULE_PATH: it would need to be a path relative to the package that you're calling catkin_package(.. CFG_EXTRAS ..) in and also make sure to install(..) the extras-file as otherwise consumers of your package will not be able to find it when using an install space.

As the paths to your package may be different in the devel and install space, you may have to use some templating to get the correct paths generated for you. gencpp does something similar (from here):

@[if DEVELSPACE]@
  ...
@[else]@
  ...
@[end if]@

See also the catkin documentation: Extracted CMake API reference for more information on this.

You can do this with an a extras-fileCFG_EXTRAS file (which is essentially a snippet of CMake) and exporting the location to it in your catkin_package(.. CFG_EXTRAS ..) call in the CMakeLists.txt of the package from which you'd like to export this.

See #q173947 for a Q&A where this is done for exporting compiler flags from a package, and #q93266 for an example where this is used to export a non-standard include path.

You should be able to append to CMAKE_MODULE_PATH in the same way, as the extras-file contains just regular CMake. Be sure to specify the correct path to CMAKE_MODULE_PATH: it would need to be a path relative to the package that you're calling catkin_package(.. CFG_EXTRAS ..) in and also make sure to install(..) the extras-file as otherwise consumers of your package will not be able to find it when using an install space.

As the paths to your package may be different in the devel and install space, you may have to use some templating to get the correct paths generated for you. gencpp does something similar (from here):

@[if DEVELSPACE]@
  ...
@[else]@
  ...
@[end if]@

See also the catkin documentation: Extracted CMake API reference for more information on this.