[CMake] Different configurations with Visual Studio

Mark Van Peteghem markvp at gmail.com
Thu Jul 1 03:12:39 EDT 2010


Thanks, this works. Actually

if(CMAKE_CONFIGURATION_TYPES)
   set(CMAKE_CONFIGURATION_TYPES Debug Release DebugMX31 ReleaseMX31)
   set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
     "Reset the configurations to what we need" FORCE)
 endif()

also works for me. I've added it to the FAQ of the Wiki. But this is only
half of what need. I actually need to make this generate settings for a
different platform as well, I mean 'platform' in the Visual Studio sense,
also called 'solution platform' in Visual Studios configuration manager,
which is Win32 by default, but I need it for both Win32 and MX31.

Can this be done with CMake? I'm afraid not, but if it is possible, how? In
the project file it is written as something like Debug|MX31, but using that
in CMake doesn't work.

Mark

2010/6/28 Michael Wild <themiwi at gmail.com>

>
> On 28. Jun, 2010, at 15:17 , Mark Van Peteghem wrote:
>
> > Hi,
> >
> > I am using CMake to generate Visual Studio project files, later also for
> > CodeBlocks.
> >
> > It seems that CMake generates four different configurations for Visual
> > Studio: Debug, Release, MinSizeRel and RelWithDebInfo. However, I need
> other
> > configuations, Debug and Release, both for Win32 and MX3, in one project
> > file. How do I change this?
> >
> > I tried this by changing *CMAKE_CONFIGURATION_TYPES *and
> CMAKE_BUILD_TYPES,
> > e.g.
> >
> > SET(CMAKE_BUILD_TYPES Debug Release DebugMX31 ReleaseMX31)
> >
> > but I have the impression that these variables cannot be changed.
> >
> > --
> > Mark
>
> You have to change CMAKE_CONFIGURATION_TYPES in the cache. Here is some
> template I use:
>
> # Xcode generator is buggy (linker flags are not inherited from compile
> flags
> # and custom configurations don't work with shared libraries)
> if(NOT CMAKE_GENERATOR STREQUAL Xcode)
>  set(CMAKE_C_FLAGS_SUPERDUPER "--super --duper" CACHE
>    STRING "Flags used by the compiler during super-duper builds")
>  set(CMAKE_EXE_LINKER_FLAGS_SUPERDUPER "--super --duper" CACHE
>    STRING "Flags used by the linker for executables during super-duper
> builds")
>  set(CMAKE_SHARED_LINKER_FLAGS_SUPERDUPER "--super --duper" CACHE
>    STRING "Flags used by the linker for shared libraries during super-duper
> builds")
>  set(CMAKE_MODULE_LINKER_FLAGS_SUPERDUPER "--super --duper" CACHE
>    STRING "Flags used by the linker for loadable modules during super-duper
> builds")
>  mark_as_advanced(CMAKE_C_FLAGS_COVERAGE CMAKE_EXE_LINKER_FLAGS_SUPERDUPER
>    CMAKE_SHARED_LINKER_FLAGS_SUPERDUPER
> CMAKE_MODULE_LINKER_FLAGS_SUPERDUPER)
>  # This variable is only set for multi-config IDE generators
>  if(CMAKE_CONFIGURATION_TYPES)
>    list(APPEND CMAKE_CONFIGURATION_TYPES SuperDuper)
>    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|SuperDuper]"
>      FORCE)
>  endif()
> endif()
>
> HTH
>
> Michael
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100701/133ea8bc/attachment.htm>


More information about the CMake mailing list