CMAKE_CONFIGURATION_TYPES considered harmful

Brad King brad.king at kitware.com
Thu Nov 6 01:18:21 CET 2008


Alexander Neundorf wrote:
> On Wednesday 05 November 2008, Brad King wrote:
>> Manuel "Sput" Nickschas wrote:
> ...
>>> While in theory and according to cmake docs this should just add the
>>> additional build configuration to a list of existing ones, in reality
>>> this adds "Debugfull" to an empty list, since CMake does not set this
>>> variable (anymore? Dunno if that was always the case...). This results in
>>> CMake always installing Debugfull, since it's set to be the only valid
>>> type.
>> The variable is used by the IDE generators like VS and Xcode which have
>> multiple configurations in a single build tree.  It should not be set
>> for Makefile generators.
> 
> So you would recommend checking the generator over setting 
> CMAKE_CONFIGURATION_TYPES to CMAKE_BUILD_TYPE initially ?
> 
> This is what I was about to do:
> 
> if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
>    set(CMAKE_BUILD_TYPE RelWithDebInfo)
>    set(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES}  
>                                  ${CMAKE_BUILD_TYPE} )
> endif (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)

The way to identify whether a generator is multi-configuration is to
check whether CMAKE_CONFIGURATION_TYPES is set.  The VS/XCode generators
set it (and ignore CMAKE_BUILD_TYPE).  The Makefile generators do not
set it (and use CMAKE_BUILD_TYPE).  If CMAKE_CONFIGURATION_TYPES is not
already set, don't set it.

-Brad


More information about the Kde-buildsystem mailing list