[cmake-developers] [CMake 0014269]: CMAKE_CONFIGURATION_TYPES does not work with Visual Studio

Mantis Bug Tracker mantis at public.kitware.com
Wed Jul 3 12:56:22 EDT 2013


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=14269 
====================================================================== 
Reported By:                dbcfd
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   14269
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2013-07-03 12:56 EDT
Last Modified:              2013-07-03 12:56 EDT
====================================================================== 
Summary:                    CMAKE_CONFIGURATION_TYPES does not work with Visual
Studio
Description: 
CMAKE_CONFIGURATION_TYPES cannot be set to work with Visual Studio (possibly
other multi configuration ides). Per 0006788, it should work by setting prior to
calling project, however this does not produce the desired behavior. 

Using the following CMake on a clean build:
    message("CONFIGS IS ${CMAKE_CONFIGURATION_TYPES}")
    set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
    message("CONFIGS IS ${CMAKE_CONFIGURATION_TYPES}")
    
    #project variables
    project(${_project} CXX)
    message("CONFIGS IS ${CMAKE_CONFIGURATION_TYPES}")
    set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
    message("CONFIGS IS ${CMAKE_CONFIGURATION_TYPES}")

The output will be 

CONFIGS IS Debug;Release
CONFIGS IS Debug;Release
CONFIGS IS Debug;Release;MinSizeRel;RelWithDebInfo
CONFIGS IS Debug;Release

Indicating that the Project command resets the cached variable.

Additional Information: 
Modules\Platform\Windows-MSVC.cmake, line 55

if(NOT CMAKE_NO_BUILD_TYPE AND CMAKE_GENERATOR MATCHES "Visual Studio")
  set (CMAKE_NO_BUILD_TYPE 1)
  set (CMAKE_CONFIGURATION_TYPES "Debug;Release;MinSizeRel;RelWithDebInfo" CACHE
STRING
     "Semicolon separated list of supported configuration types, only supports
Debug, Release, MinSizeRel, and RelWithDebInfo, anything else will be ignored.")
  mark_as_advanced(CMAKE_CONFIGURATION_TYPES)
endif()

This should only set CMAKE_CONFIGURATION_TYPES if not already set:

if(NOT CMAKE_NO_BUILD_TYPE AND CMAKE_GENERATOR MATCHES "Visual Studio")
  set (CMAKE_NO_BUILD_TYPE 1)
  if(NOT CMAKE_CONFIGURATION_TYPES)
     set (CMAKE_CONFIGURATION_TYPES "Debug;Release;MinSizeRel;RelWithDebInfo"
CACHE STRING
     "Semicolon separated list of supported configuration types, only supports
Debug, Release, MinSizeRel, and RelWithDebInfo, anything else will be ignored.")
  endif()
  mark_as_advanced(CMAKE_CONFIGURATION_TYPES)
endif()


====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2013-07-03 12:56 dbcfd          New Issue                                    
======================================================================




More information about the cmake-developers mailing list