Ask Your Question

Best practice for incorporating catkin into larger CMake project?

asked 2013-04-29 10:16:58 -0500

dcconner gravatar image

updated 2013-04-29 10:17:24 -0500

I would like to incorporate a few catkin-based ROS groovy packages into a larger CMake project that does not use ROS or catkin.

Catkin requires that the top-level directory from which you invoke catkin_make (e.g. the catkin workspace) does not contain a CMakeLists.txt file.

I have a conceptual out a hack to invoke the catkin_make from above without including a CMakeLists.txt in the workspace, and use an external variable definition to pass information into catkin_make, but would assume others have better solutions.

Can anyone share any best practices for incorporating ROS into larger non-ROS projects?

edit retag flag offensive close merge delete


I get a "famous question" badge, but no answers/discussion. Looks like I'll have to do my hack.

dcconner gravatar image dcconner  ( 2013-05-17 05:43:20 -0500 )edit

I guess so. When no one responds it's generally because no one knows the answer.

joq gravatar image joq  ( 2013-05-17 05:52:19 -0500 )edit

ROS brings a similar amount of baggage to cmake as qt does. Not much but more than I'd like. Integrating ros code into an existing cmake project is straightforward. The catkin CMakeLists.txt guide will tell you what you need to know.

hauptmech gravatar image hauptmech  ( 2015-11-25 23:47:27 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2013-05-17 07:25:01 -0500

William gravatar image

updated 2013-05-17 07:35:52 -0500

The best practice would be to build the ROS stuff in a catkin workspace and then make install those packages separate from your other project and then build your project on top of the installed catkin packages, which can be found using find_package or pkg-config.

The other good thing to do would be to just use catkin for all of your project, so that your "larger" project is just another package in the catkin workspace, this is the best way to get access (find_package) to all of the packages in the catkin workspace at build time in a single CMake invocation, and this is what catkin was designed to do.

If you are dead set on integrating several catkin packages in to a single CMake project, another strategy might be to just have a catkin workspace in your project and call add_subdirectory on the catkin workspace. I haven't tried this and I am not sure what side effects this might have, but you are welcome to try it.

Either way I would not call catkin_make directly from another CMake project. All catkin_make does is something like this:

# In catkin workspace with packages in the `src` folder
cd src
catkin_init_workspace # This creates the CMakeLists.txt in the top of the workspace
cd ..
mkdir build
cd build
cmake ../src -DCMAKE_INSTALL_PREFIX=../install -DCATKIN_DEVEL_SPACE=../devel

There is no magic in catkin_make which is required to build a catkin workspace. You should be able to copy over the top-level.cmake file to the catkin workspace in your project and use add_subdirectory on it.

edit flag offensive delete link more

answered 2016-04-03 13:29:13 -0500

jdcarp gravatar image

dcconner, could you please elaborate on your hack method? I am working on a similar project, and would love to hear extra ideas because building my old system with catkin is proving to be pretty difficult.

edit flag offensive delete link more



Unfortunately it has been a while, and I not longer have access to the "hack" setup

dcconner gravatar image dcconner  ( 2016-07-06 18:46:30 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-04-29 10:16:58 -0500

Seen: 891 times

Last updated: May 17 '13