CATKIN_DEVEL_PREFIX in catkin_make vs catkin tools
I'm trying to make our build compatible with catkin_make and catkin tools, but how CATKIN_DEVEL_PREFIX is handled in the two tools is causing me some trouble.
We have some (non-ROS) tools that generate headers that need to be included by the current package being built, and by downstream packages. Our pure-cmake build system would create these headers in the out-of-source build directory and install them into the install directory. Downstream packages would include the $INSTALL/include directory and all would be well. We adapted our build to be catkin_make compatible by copying the files into ${CATKIN_DEVEL_PREFIX}/include at configure time, and downstream packages could find them by adding ${CATKIN_DEVEL_PREFIX}/include to their include path.
This doesn't work with catkin tools, because CATKIN_DEVEL_PREFIX points to a devel/.private directory and then symlinks content into devel space. Is there a variable available at configure time in CMake that points to workspace/devel that is available in both catkin_make and catkin tools?
I know this problem can be solved by making foo-extras.cmake.develspace.in and foo-extras.cmake.installspace.in for each project, but that'll be a huge pain. A variable that is consistent between the two tools that points to the workspace/devel directory would be a lot more straightforward.
Thanks, -Mark
Edit: Creating a minimal example would take a fair amount of work, I'll point to some of the relevant files and hopefully that will be sufficient.
Here's our cmake macro for generating source from RTI DDS IDL: https://github.com/mallanmba/irg_cmak...
Here's a CMakeLists.txt that uses the macro: https://github.com/mallanmba/soraCore...
There's a block at the end that checks for catkin_FOUND
and copies the generated headers into devel space. If that block is not there, none of the headers show up in devel space. I've never observed catkin_make or catkin_tools putting headers into devel space unless I explicitly copy them there. How is the "automatic" placement of includes in devel supposed to work?
The issue that I'm having with CATKIN_DEVEL_PREFIX
between catkin_make and catkin tools is that catkin_make sets that variable to foo_ws/devel
and catkin tools sets it to foo_ws/devel/.private/bar_project
and then symlinks into foo_ws/devel
. If I have project_B that depends on generated headers from project_A, and I add ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_INCLUDE_DESTINATION}
to the include path of a project_B, it works fine for catkin_make. But it fails for catkin tools because ${CATKIN_DEVEL_PREFIX}
is pointing to foo_ws/devel/.private/project_B, and project_B can't see project_A's generated headers.
In response to the "automatic" placement of headers into the devel space, if the package is a cmake package, then the catkin tools will
make install
with the install prefix set to the devel space. If it is a catkin package then it does need to be copied.I think the issue is that you assume that two different packages will share the same devel space. I think your packages would also fail to work if you split them between two catkin workspaces (even if you build them both with
catkin_make
).Instead you should
find_package
project_A from project_B and add the include directories exported by project_A in theCMakeLists.txt
for project_B.Put another way, Project A generates files and puts them in a folder, then exports that folder in the
project_A_INCLUDE_DIRS
variable and then project B doesfind_package(... project_A)
and adds the folder it exported as an include directory with the CMake macroinclude_directories(...)
.Is there an easier way to export
foo_INCLUDE_DIRS
than having to createfoo-extras.cmake.installspace.in
andfoo-extras.cmake.develspace.in
for each project? Thecatkin_package()
INCLUDE_DIRS is relative toCMAKE_CURRENT_SOURCE_DIR
which doesn't helpThis line from
gencpp
(which also generates header files like this and makes them available in the devel space), adds the include directory to be exported automatically by thecatkin_package
call: https://github.com/ros/gencpp/blob/in...