Best way to include a header generated with configure_file
Hi there,
In a few packages, especially when porting third-party software to catkin, I encounter the problem of auto-generated headers. In a single-package scenario, it is pretty easy to handle, as I just have to play with include_directories()
and the matter is settled.
As for the install space, an appropriate install()
rule easily takes care of it.
Things get more complicated when dealing with devel space. For example, I would like my fooConfig.cmake
to contain a link to the devel space include folder, that would contain the header generated from a template with configure_file()
, for example. The same goes with pkg-config files.
I looked around and could not find any documentation or best practices on the matter.
So far, I have tested adding a cmake/foo-extras.cmake.in
file like the following:
if(@DEVELSPACE@) list(APPEND @PROJECT_NAME@_INCLUDE_DIRS @CATKIN_DEVEL_PREFIX@/include) endif()
and then in my CMakeLists.txt
I have something akin to this:
catkin_package( CFG_EXTRAS foo-extras.cmake ) set(devel_pkg_inc ${CATKIN_DEVEL_PREFIX}/include/${PROJECT_NAME}) configure_file(foo.h.in ${devel_pkg_inc}/foo.h) install(FILES ${devel_pkg_inc}/foo.h DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
It does the job for me, but it looks a bit clunky. Is there any catkin-ish way of doing this? Am I missing anything obvious?
cc @Dirk Thomas