MantisBT - CMake
View Issue Details
0015577CMakeCMakepublic2015-05-20 11:382015-11-02 09:15
Cedric Guerin 
Brad King 
normalminoralways
closedfixed 
CMake 3.2.2 
CMake 3.3CMake 3.3 
0015577: The 'project' command overwrites CMAKE_CONFIGURATION_TYPES.
If you have cmake files in a hierarchy of directories like in the sample provided, and use additional project commands in subdirectories (in my case in order to generate additional Visual Studio Solutions with only a subset of all the libraries generated), the project command will change the value of CMAKE_CONFIGURATION_TYPES to what appears to be a merge of the initial value outside any project declaration and it's current value, and this value will even be stored in the cache, affecting completely unrelated directory subhierarchies.
Simply run cmake on the provided sample.
The output of the provided sample in a fresh build directory is:

CMAKE_CONFIGURATION_TYPES at start is :
CMAKE_CONFIGURATION_TYPES before global project is : Debug;Release;Default
CMAKE_CONFIGURATION_TYPES after global project is : Debug;Release;Extra
CMAKE_CONFIGURATION_TYPES before libraries project is : Debug;Release;Extra
CMAKE_CONFIGURATION_TYPES after libraries project is : Debug;Release;Default;Extra
CMAKE_CONFIGURATION_TYPES for runtimes is : Debug;Release;Default;Extra

While the expected output whould be for CMAKE_CONFIGURATION_TYPES to remain at Debug;Release;Extra once set.

Note that you can remove the assigment to CMAKE_CONFIGURATION_TYPES outside any project, it's only there to help identify what occurs. Without it, cmake considers that the value outside of any project is the one stored in CMakeCache.txt (or the 4 default configurations if there is no CMakeCache.txt), but the overall behavior is the same.
No tags attached.
zip Project.zip (1,953) 2015-05-20 11:38
https://public.kitware.com/Bug/file/5463/Project.zip
Issue History
2015-05-20 11:38Cedric GuerinNew Issue
2015-05-20 11:38Cedric GuerinFile Added: Project.zip
2015-05-21 09:18Brad KingNote Added: 0038789
2015-05-21 09:18Brad KingAssigned To => Brad King
2015-05-21 09:18Brad KingStatusnew => resolved
2015-05-21 09:18Brad KingResolutionopen => fixed
2015-05-21 09:18Brad KingFixed in Version => CMake 3.3
2015-05-21 09:18Brad KingTarget Version => CMake 3.3
2015-11-02 09:15Robert MaynardNote Added: 0039820
2015-11-02 09:15Robert MaynardStatusresolved => closed

Notes
(0038789)
Brad King   
2015-05-21 09:18   
This refactoring should fix it:

 VS: Do not accumulate configurations globally
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2f4bb4e9 [^]
(0039820)
Robert Maynard   
2015-11-02 09:15   
Closing resolved issues that have not been updated in more than 4 months.