Adding a Custom Configuration in CMake

September 20, 2011

To add a custom configuration to a CMake build (which only applies to multi-generators such as Visual Studio):

list(APPEND CMAKE_CONFIGURATION_TYPES DEBUGX64)
list(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
 
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
    "Semicolon separated list of supported configuration types [Debug|Release|MinSizeRel|RelWithDebInfo|Debug-x64]"
    FORCE)
 
set(CMAKE_C_FLAGS_SUPERDUPER "-flagone -flagtwo" CACHE STRING
    "Flags used by the compiler during debugx64 builds")
set(CMAKE_CXX_FLAGS_SUPERDUPER "-flagone -flagtwo" CACHE STRING
    "Flags used by the compiler during debugx64 builds")
 
set(CMAKE_EXE_LINKER_FLAGS_SUPERDUPER "-flagone -flagtwo" CACHE STRING
    "Flags used by the linker for executables during debugx64 builds")
set(CMAKE_SHARED_LINKER_FLAGS_SUPERDUPER "-flagone -flagtwo" CACHE STRING
    "Flags used by the linker for shared libraries during debugx64 builds")
set(CMAKE_MODULE_LINKER_FLAGS_SUPERDUPER "-flagone -flagtwo" CACHE STRING
    "Flags used by the linker for loadable modules during debugx64 builds")
 
mark_as_advanced(CMAKE_C_FLAGS_DEBUGX64 CMAKE_CXX_FLAGS_DEBUGX64
                 CMAKE_EXE_LINKER_FLAGS_DEBUGX64 CMAKE_SHARED_LINKER_FLAGS_DEBUGX64 CMAKE_MODULE_LINKER_FLAGS_DEBUGX64)

One Response to “Adding a Custom Configuration in CMake”

  1. Thaks for sharing ! I found this page while trying to add a new build type to my cmake.

    I thought it was the answer but unfortunately, it didn’t work. That was because I was confused between configurations and build type.

    For adding a new build type (not a configuration), go here : http://stackoverflow.com/questions/11437692/how-to-add-a-custom-build-type-to-cmake-targetting-make

Leave a Reply