This question is about setting up CMake configuration files so as to serve plain users as well as co-developers.
Both user groups will need to compile. The difference between them is that co-developers, before compiling, will run a number of code generators or converters like flex/bison
, swig
or pod2man
. These tools shall not be provided with our source package, but be required as external dependences. Plain users, however, shall be provided with all auto-generated code so that they do not need to install and run any tool other than cmake, make, and a compiler.
Now the question: How to set up the main CMakeLists.txt
so that upon cmake
we just compile, whereas upon cmake <expert flag>
all auxiliary tools are required and run? As an obvious refinement, more fine-grained flags should allow to switch single tools on or off.
As easy as
option(DEVELOPER_MODE "This will run developer tools during build" OFF)
...
if(DEVELOPER_MODE)
add targets for flex and stuff
endif()
Now configure your build with cmake -D DEVELOPER_MODE=YES ..
to enable it.