MantisBT - CMake
View Issue Details
0015879CMakeCMakepublic2015-12-11 16:562016-05-02 08:30
Javier Martinez 
 
normalmajoralways
closedunable to reproduce 
WindowsWindows7
CMake 3.4.1 
 
0015879: Wrong configuration name emitted by generator expression
CMake has issues with the $<CONFIG> and $<CONFIG:name> generator expressions when one configuration name is a substring of another. The attached reproducer has Debug, Release and ReleaseInternal as the configuration names. In this case ReleaseInternal is used instead of Release.
- Generate solution (I placed the CMakeLists/txt file in the /bin folder and used cmake.exe . to generate the solution)
- Open the generated solution Test.sln
- Open the properties for TestProject -> CMake Rules ->stamp.txt.rule
- Click on Configuration Properties -> Custom Build Tools -> General
- On Configuration select Release
- Inspect the Command Line property, it reads "Printing comment for ReleaseInternal" instead of "Printing comment for Release"
Tested with CMake version cmake-3.4.1-win32-x86
No tags attached.
txt CMakeLists.txt (387) 2015-12-11 16:56
https://public.kitware.com/Bug/file/5588/CMakeLists.txt
png CMake_0015879_1.png (135,783) 2015-12-15 14:13
https://public.kitware.com/Bug/file/5591/CMake_0015879_1.png
png
Issue History
2015-12-11 16:56Javier MartinezNew Issue
2015-12-11 16:56Javier MartinezFile Added: CMakeLists.txt
2015-12-14 08:46Brad KingNote Added: 0039978
2015-12-15 08:47Brad KingStatusnew => resolved
2015-12-15 08:47Brad KingResolutionopen => unable to reproduce
2015-12-15 14:13Javier MartinezFile Added: CMake_0015879_1.png
2015-12-15 14:14Javier MartinezNote Added: 0039986
2015-12-17 08:28Brad KingNote Added: 0039993
2016-05-02 08:30Robert MaynardNote Added: 0040986
2016-05-02 08:30Robert MaynardStatusresolved => closed

Notes
(0039978)
Brad King   
2015-12-14 08:46   
With CMake 3.4.1 and the VS 2015 generator I get the expected content in the .vcxproj file:

$ grep -B 1 'Printing comment' TestProject.vcxproj
      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E echo Printing comment for Debug
--
      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">setlocal
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E echo Printing comment for Release
--
      <Command Condition="'$(Configuration)|$(Platform)'=='ReleaseInternal|Win32'">setlocal
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E echo Printing comment for ReleaseInternal

I also see the proper output at build time:

 $ cmake --build . --config Release --target TestProject
 ...
 Printing comment for Release

 $ cmake --build . --config ReleaseInternal --target TestProject
 ...
 Printing comment for ReleaseInternal
(0039986)
Javier Martinez   
2015-12-15 14:14   
I can confirm that the correct output is printed when I compile with the VS 2013 IDE. However, if the command is inspected in the IDE as the reproduction steps indicate the wrong command is displayed. Is this a CMake or a VS issue?
(0039993)
Brad King   
2015-12-17 08:28   
If the correct output is generated by the build, and the correct content appears in the .vcxproj file, then this is almost certainly a VS issue. CMake is generating the proper content into the file. If you do try to report this to MS, please first reproduce it in .vcxproj file created purely through VS and not with CMake. That will make it clearer.
(0040986)
Robert Maynard   
2016-05-02 08:30   
Closing resolved issues that have not been updated in more than 4 months.