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
make
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.
I get a "famous question" badge, but no answers/discussion. Looks like I'll have to do my hack.
I guess so. When no one responds it's generally because no one knows the answer.
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.