[CMake] Detect build type
Brad King
brad.king at kitware.com
Thu Apr 21 13:00:11 EDT 2005
Filipe Sousa wrote:
> Is there a better way to know if CMake is generating files for debug or
> release builds than using CMAKE_BUILD_TYPE?
>
> I've been using this:
> IF(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
> SET(CMAKE_DEBUG_MODE 1)
> ENDIF(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
>
> IF(CMAKE_BUILD_TYPE MATCHES "[Re][Ee][Ll][Ee][Aa][Ss][Ee]")
> SET(CMAKE_RELEASE_MODE 1)
> ENDIF(CMAKE_BUILD_TYPE MATCHES "[Re][Ee][Ll][Ee][Aa][Ss][Ee]")
Code like this will work only for the makefile generators. Project file
generators usually produce all configurations in the same build tree and
it is up to the user at build-time to select the desired build type.
This information is not available at cmake-time.
What kind of configuration do you do based on the build type? There is
probably a way to convert this to build-time so that it will work for
all generators.
-Brad
More information about the CMake
mailing list