With our CMake build system I build some libraries and some executables. The build products are all output to a specific folder.
Now the problem is I have a VS2010 and a VS2008 toolchain but I only need the VS2008 toolchain for VS2008 libraries. The output executables are win32 target for both toolchains so I only need to build the executables once via the VS2010 toolchain while the VS2008 toolchain should just skip the executables and build only the desired libraries (which saves build time).
The CMake base scripts and overall setup may also be delivered to customers in the future so it would be very nice if there is a way in CMake to disable certain targets, like all executables in a generic way. Otherwise i have to write many big IF( BUILD_EXECUTABLES ) ... ENDIF() constructs around my executables setup in my CMakeLists.txt, without CMake giving me errors when I forget them.
The build is triggered via some batch files. Ideally i want to pass a variable to cmake via the -D option (e.g. "-D BUILD_EXECUTABLES=false")
I tried to wrap the ADD_EXECUTABLE macros but that does not work since I have calls like TARGET_LINK_LIBRARIES which then complain about the nonexistent target.
I could also set the output directory to some garbage folder which could be deleted afterwards, but that (as already mentioned) would not save build time (We have a quite huge project)
Any ideas how to accomplish that in clean and generic way?