[CMake] New build configuration based off existing configuration?

Glenn Coombs glenn.coombs at gmail.com
Mon Jun 6 11:48:37 EDT 2011


This is what I do:

# Add configuration for ReleaseNoOutfiles builds based on the release
configuration
#
=================================================================================
set(CMAKE_C_FLAGS_RELEASENOOUTFILES
${CMAKE_C_FLAGS_RELEASE}                CACHE STRING "Flags used by the
compiler during ReleaseNoOutfiles builds")
set(CMAKE_CXX_FLAGS_RELEASENOOUTFILES
${CMAKE_CXX_FLAGS_RELEASE}                CACHE STRING "Flags used by the
compiler during ReleaseNoOutfiles builds")
set(CMAKE_EXE_LINKER_FLAGS_RELEASENOOUTFILES
${CMAKE_EXE_LINKER_FLAGS_RELEASE}        CACHE STRING "Flags used by the
linker for executables during ReleaseNoOutfiles builds")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASENOOUTFILES
${CMAKE_SHARED_LINKER_FLAGS_RELEASE}    CACHE STRING "Flags used by the
linker for shared libraries during ReleaseNoOutfiles builds")
set(CMAKE_MODULE_LINKER_FLAGS_RELEASENOOUTFILES
${CMAKE_MODULE_LINKER_FLAGS_RELEASE}    CACHE STRING "Flags used by the
linker for loadable modules during ReleaseNoOutfiles builds")

mark_as_advanced(
    CMAKE_C_FLAGS_RELEASENOOUTFILES
    CMAKE_CXX_FLAGS_RELEASENOOUTFILES
    CMAKE_EXE_LINKER_FLAGS_RELEASENOOUTFILES
    CMAKE_SHARED_LINKER_FLAGS_RELEASENOOUTFILES
    CMAKE_MODULE_LINKER_FLAGS_RELEASENOOUTFILES
)

# This variable is only set for multi-config IDE generators like MSVC
if(CMAKE_CONFIGURATION_TYPES)
    list(APPEND CMAKE_CONFIGURATION_TYPES ReleaseNoOutfiles)
    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|ReleaseNoOutfiles]"
        FORCE)
endif()

I don't know if I have set *all* the relevant variables but it seems to work
for me so far.  It would definitely be nicer if cmake had a built-in command
to create new build configurations based upon an existing one.  Something
like:

  create_build_config(ReleaseNoOutfiles Release)

--
Glenn

On 6 June 2011 04:50, Ivan Neeson <zzymyn at gmail.com> wrote:

> Is it possible to easily add a new build configuration that is identical to
> an existing configuration (for example "MinSizeRel2" which has exactly the
> same settings as "MinSizeRel")?
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110606/1348aa0f/attachment.htm>


More information about the CMake mailing list