Optionally build a package with catkin
I have a package that provides a library. This library performs functions that do not explicitly rely on ROS and I want to be able to use this library in non-ROS contexts, i.e. in c++ programs I build with pure CMake.
I am looking for a way to set up my package, specifically the CMakeLists.txt, such that this package builds both as a catkin package and stand alone. When building with catkin, I want to declare the library s.t. other ROS packages can find and use it. In the pure CMake case I want to just build the library and have other packages find it themselves, e.g. with a FindMYPACKAGE.cmake.
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). On systems without ROS, find_package(catkin ...)
naturally causes an error, so I can't check for catkin that way.
What variables exist that are already set at the top of a packages CMakeLists.txt with which I can check if catkin is the build tool in use?
Thank you for your help