Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The proposed way is ok. Generating the header into the devel space is exactly what should be done. Also the install rule is necessary - as is.

But you can achieve the same functionality without an extra file. First to make it work for code compiler in your package you need to add the include folders:

# also assuming that you also have static headers in the include folder of your package
include_directories(include ${CATKIN_DEVEL_PREFIX}/include)

You should always only add the include folder (rather then the package specific subfolder in it) and then include your code with the package name as a namespace (e.g. #include <pkgname/myheader.h).

Second to make packages work which depend on yours you have to export both include locations:

catkin_package(INCLUDE_DIRS include ${CATKIN_DEVEL_PREFIX}/include)

For the install case it will work correctly since the include folder in install space will contain your static headers form the package include folder (if you have also installed them) as well as the header installed from the devel space. Again keep in mind that all your headers should be in a subfolder of include and should also be referenced like this in code.