[CMake] setting a default build type

Alan W. Irwin irwin at beluga.phys.uvic.ca
Thu Sep 7 10:51:05 EDT 2006


On 2006-09-07 00:56-0700 Brandon J. Van Every wrote:

> On MSVC my CMakeLists.txt generates Debug, Release, MinSizeRel, and 
> RelWithDebInfo build types.  I want to keep all 4 of 'em.  I want to select 
> MinSizeRel as the default build, so that if an end user just fires up 
> BUILD_ALL and does nothing else, he'll get a MinSizeRel build.  The default 
> default is "Debug" and that's not what I want.
> So, is there a mechanism to 
> specify the default build type?  I was unable to deduce it from the docs if 
> there is one.  Seems clear enough how to ship *one* build type, I'd just do 
> (SET CMAKE_BUILD_TYPE MinSizeRel).  But I want all 4 to be shipped.

Its a cached variable.  So I think what you want is

SET (CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "Flags used by the compiler
during all build types.")

That gives you the default you want plus the user should be able to override
that default with a -D option or appropriate GUI action.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the Yorick front-end to PLplot (yplot.sf.net); the
Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list