[CMake] Problems setting CMAKE_CONFIGURATION_TYPES for Visual Studio

Eric Clark eclark at ara.com
Tue May 28 16:01:31 EDT 2013


Our projects limit the types to just Debug and Release. However, what I found was that you had to set the variable before every call to project(...). What we did was we created a module called BuildTypes.cmake and include it first thing in every list file. The file has one line of code in it that looks like this:

set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE TYPE INTERNAL FORCE)

This does the trick for us. Hope this helps...

Eric

From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf Of gaga bla
Sent: Tuesday, May 28, 2013 12:55 PM
To: cmake at cmake.org
Subject: [CMake] Problems setting CMAKE_CONFIGURATION_TYPES for Visual Studio

Hello, I have problems reducing available configuration types for a Visual Studio project.
No matter what I do, the project always contains all four configuration types.

I have two files involved, I tried to strip everything that seemed to be unimportant:

CmakeLists.txt (Main file):
------------------------------------
include("... Helpers.cmake")
configureMyProject("MyProject")
message("Config types (outside): ${CMAKE_CONFIGURATION_TYPES}")
------------------------------------

Helpers.cmake:
------------------------------------
if(__myhelpers)
                return()
endif()
set(__myhelpers YES)

function(configureMyProject MY_NAME ........)
  set(CMAKE_CONFIGURATION_TYPES "Debug;RelWithDebInfo" CACHE STRING "" FORCE)
  message("Config types (before): ${CMAKE_CONFIGURATION_TYPES}")
  project(${MY_NAME})
  message("Config types (after): ${CMAKE_CONFIGURATION_TYPES}")
  set(CMAKE_CONFIGURATION_TYPES "Debug;RelWithDebInfo" CACHE STRING "" FORCE)
  message("Config types (after 2): ${CMAKE_CONFIGURATION_TYPES}")
  ...
  add_library(...)
  ...
endfunction()
------------------------------------

I then get the following output:
------------------------------------
Config types (before): Debug;RelWithDebInfo
Config types (after): Debug;Release;MinSizeRel;RelWithDebInfo
Config types (after 2): Debug;RelWithDebInfo
Config types (outside): Debug;RelWithDebInfo
------------------------------------

So it seems to me, that the call of the project-function resetted the configuration types and created then the project accordingly.
Is this a bug or am I doing something wrong? Does anyone know a workaround?

Kind regards
Janosch Scharlipp
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130528/98a9b517/attachment-0001.htm>


More information about the CMake mailing list