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
CMake targets have two properties which control if a target is built by default. The first one is EXCLUDE_FROM_ALL
. It indicates if the target is excluded from the default build target. For Makefile generators, typing make
will not trigger a build of a target whose EXCLUDE_FROM_ALL
property is set to 1.
The other one is EXCLUDE_FROM_DEFAULT_BUILD
and only applies to Visual Studio generators. If it is set to 1, the target will not be part of the default build when you invoke the "Build Solution" menu command.
You could set the values of both properties for executable targets depending on the option BUILD_EXECUTABLES
:
if (NOT BUILD_EXECUTABLES)
set_target_properties(exe1 exe2 PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)
endif()