View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014269CMakeCMakepublic2013-07-03 12:562013-12-02 08:51
Reporterdbcfd 
Assigned ToBrad King 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake 2.8.11.1 
Target VersionCMake 2.8.12Fixed in VersionCMake 2.8.12 
Summary0014269: CMAKE_CONFIGURATION_TYPES does not work with Visual Studio
DescriptionCMAKE_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 InformationModules\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()

TagsNo tags attached.
Attached Fileszip file icon Reproduce.zip [^] (813 bytes) 2013-07-03 14:33

 Relationships

  Notes
(0033466)
dbcfd (reporter)
2013-07-03 13:06

The additional information is possibly unneeded. It seems that cache variables cannot be set in that script, and CMAKE_CONFIGURATION_TYPES will always be unset.
(0033469)
dbcfd (reporter)
2013-07-03 14:34

Added a set of CMake files to reproduce issue. If macro ConfigurationFixer is commented out in CMakeLists.txt, configurations will not be set properly. If macro remains in file, configurations will be set properly.
(0033471)
dbcfd (reporter)
2013-07-03 15:03

cmMakefile.cxx, line 650

Project command is required for top level CMakeLists.txt. The pulled in file has a macro which has the project command, but since the macro is not evaluated at this time, cmake provides a project call via cmListFileCache.

By including a project call (even one that is not used, but in a macro), the project call in the included file will correctly be evaluated after the caching of the configuration types.
(0033474)
Brad King (manager)
2013-07-03 16:26

This may have been fixed by a recent post-2.8.11 change:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=42bb42d1 [^]
(0033477)
Brad King (manager)
2013-07-03 16:53

Re 0014269:0033474: Local testing tells me that commit 42bb42d1 fixed this issue.
(0033478)
dbcfd (reporter)
2013-07-03 17:06

Reproduction was done using latest code in github.

The issue is where a project command is in a file pulled in by include() (which should just drop it inline). cmMakefile.cxx will then not see a project command in the top level CMakeLists.txt, and automatically add one, which will set generator types to the standard 4.

You may want to close this issue and reopen a clearer issue with the reproduction steps. I'll test setting CMAKE_CONFIGURATION_TYPES after project, which would allow the project command to be added to the main file, rather than in an included file.
(0033481)
dbcfd (reporter)
2013-07-03 18:46

Latest code in github still has issue where calling set(CMAKE_CONFIGURATION_TYPES) after project will not produce correct configurations, either from the same CMakeLists.txt as project() or via an included macro, on the first run.

Subsequent calls to cmake will produce the correct configurations.
(0033498)
Brad King (manager)
2013-07-08 08:30

The issue reported mentions nothing about include()-ing the project command, and the fix linked in 0014269:0033474 does fix what is actually reported. I'm resolving this again.

However, I've also added documentation to clarify that you can't include() a file to call project():

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4a711687 [^]

If you *really* need to do that then try

 project(MyProjectTop NONE)

to satisfy CMake's requirement and then include() files that call enable_language(). However, also note the enable_language() documentation:

 http://www.cmake.org/cmake/help/v2.8.11/cmake.html#command:enable_language [^]
 This command must be called on file scope (not inside a function)...

If you need further help with that approach please ask on the mailing list.
(0034636)
Robert Maynard (manager)
2013-12-02 08:51

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2013-07-03 12:56 dbcfd New Issue
2013-07-03 13:06 dbcfd Note Added: 0033466
2013-07-03 14:33 dbcfd File Added: Reproduce.zip
2013-07-03 14:34 dbcfd Note Added: 0033469
2013-07-03 15:03 dbcfd Note Added: 0033471
2013-07-03 16:26 Brad King Note Added: 0033474
2013-07-03 16:53 Brad King Note Added: 0033477
2013-07-03 16:53 Brad King Assigned To => Brad King
2013-07-03 16:53 Brad King Status new => resolved
2013-07-03 16:53 Brad King Resolution open => fixed
2013-07-03 16:53 Brad King Fixed in Version => CMake 2.8.12
2013-07-03 16:53 Brad King Target Version => CMake 2.8.12
2013-07-03 17:06 dbcfd Note Added: 0033478
2013-07-03 17:06 dbcfd Status resolved => feedback
2013-07-03 17:06 dbcfd Resolution fixed => reopened
2013-07-03 18:46 dbcfd Note Added: 0033481
2013-07-03 18:46 dbcfd Status feedback => assigned
2013-07-08 08:30 Brad King Note Added: 0033498
2013-07-08 08:30 Brad King Status assigned => resolved
2013-07-08 08:30 Brad King Resolution reopened => fixed
2013-12-02 08:51 Robert Maynard Note Added: 0034636
2013-12-02 08:51 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team