[CMake] setting a default build type

Brandon J. Van Every bvanevery at gmail.com
Thu Sep 7 13:52:29 EDT 2006


Alan W. Irwin wrote:
> On 2006-09-07 09:35-0700 Brandon J. Van Every wrote:
>
>> Alan W. Irwin wrote:
>>> 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.
>>
>> I don't think this works for shipping 4 build types.  I don't want 
>> them, by default, to all behave as the same build type.
>
> Could you explain in more detail just what you mean by "shipping 4 build
> types"? (1) Is that giving the user the option of 4 different build 
> types with a
> particular default?  

Yes.  What currently comes out of CMake in VS7.1 is 4 different build 
types that the user can select, and the default is "Debug."  If the user 
does nothing but run BUILD_ALL, she'll get a debug build.  We'd rather 
it be a Release or MinSizeRel build.

> (2) Do you want to have the user build all 4 build types
> in the same CMake run? 

The user can enable this from VS7.1 if they want to.  They would select 
"Batch Build."  We're not interested in doing a batch build by default.

>
>
> The first interpretation of your request is easy to supply. CMake already
> allows the user to specify one of a list of build types.  All the 
> above SET
> command does is change the default build type (which is what you asked 
> for)
> while still allowing the user to choose something different in ccmake (or
> whatever GUI front-end they use) if they prefer a build type that is
> different than the default MinSizeRel. 

Ok I will try it and report back.  I'm in the middle of tearing 
something else up at this exact moment.


Cheers,
Brandon Van Every




More information about the CMake mailing list