I have a project that contains a visual debugger that I want to build only if a group of packages were found. I don't want to force a user that just want to build the base application to install all the debugger dependencies, so I don't mark then as REQUIRED when running find_package().
Right now my build looks like this:
./CMakeList
find_package(gazebo)
find_package(OpenGL)
find_package(GLUT)
add_subdirectory(debugger)
./debugger/CMakeList
if(NOT gazebo_FOUND OR NOT OpenGL_FOUND OR NOT GLUT_FOUND)
return()
endif()
This works just fine, but as the list of dependencies for the debugger grows, using this if to enable/disable the debugger build looks clumsy.
Is there a better alternative to enable the build of this sub-directory base on the result of find_package()?
The debugger is not the only thing in my project that I enable/disable this way, so I need a generic solution for enabling features based on the packages found.