ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I can already do this by manually defining my own variable in CMakeLists.txt, set(ROS 1), and then only doing catkiny stuff if that's defined. I tried using catkin_FOUND for this, but I have two problems: Even when the package is not actually in a catkin workspace and I'm not building with the catkin command, catkin_FOUND is true (on systems with ROS installed).

Is that even without having sourced the distribution setup.bash? A quick test on my machine shows that find_package(catkin ..) actually fails if I don't have setup.bash sourced.

On systems without ROS, find_package(catkin ...) naturally causes an error, so I can't check for catkin that way.

Unless you add the QUIET argument. As that suppresses errors, and lets you use something like:

find_package(catkin QUIET)
if (catkin_FOUND)
  ..
else()
  ..
endif()

This won't error out, even if Findcatkin.cmake isn't on the CMake search path.

As to your question: the above technique only allows you to automatically skip building the ROS parts if ROS isn't installed (or can't be found). If it is found, your catkiny stuff will always still be build. To avoid that, I don't think you can avoid adding a CMake option that can be set by your user.