0
$\begingroup$

Rosanswers logo

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_cmake/blob/catkin_build/Modules/GenerateRtiDdsIdl.cmake

Here's a CMakeLists.txt that uses the macro: https://github.com/mallanmba/soraCore/blob/master/knRapid/src/rapidDds/CMakeLists.txt

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.


Originally posted by mallanmba on ROS Answers with karma: 46 on 2016-11-23

Post score: 0


Original comments

Comment by William on 2016-12-07:
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.

Comment by William on 2016-12-07:
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).

Comment by William on 2016-12-07:
Instead you should find_package project_A from project_B and add the include directories exported by project_A in the CMakeLists.txt for project_B.

Comment by William on 2016-12-07:
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 does find_package(... project_A) and adds the folder it exported as an include directory with the CMake macro include_directories(...).

Comment by mallanmba on 2016-12-07:
Is there an easier way to export foo_INCLUDE_DIRS than having to create foo-extras.cmake.installspace.in and foo-extras.cmake.develspace.in for each project? The catkin_package() INCLUDE_DIRS is relative to CMAKE_CURRENT_SOURCE_DIR which doesn't help

Comment by William on 2016-12-07:
This 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 the catkin_package call: https://github.com/ros/gencpp/blob/indigo-devel/cmake/gencpp-extras.cmake.em#L54

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

If your packages are plain cmake, then catkin tools will "install" all the files to the devel space, so you need not copy the files. If you packages are catkin packages, then the CATKIN_DEVEL_PREFIX cmake variable should be set. I don't see any reason this shouldn't work in catkin tools as it does in catkin_make. Please provide a minimal example of the problem or instructions on how to reproduce the issue with your packages if you want someone to look into it in more detail.


Originally posted by William with karma: 17335 on 2016-11-28

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.