MantisBT - CMake
View Issue Details
0015014CMakeCMakepublic2014-07-10 12:132016-06-10 14:31
Gunnar Roth 
Kitware Robot 
normalminoralways
closedmoved 
Windowsall
CMake 3.0 
 
0015014: for better release debbuging support for /d2Zi+ option should be added for vs2012 and up
since vs2012 the option /d2Zi+ is supported by compiler which created much better debug info for release build and the debugger can actually use it. there is only a slight increase in pdb size. see http://randomascii.wordpress.com/2013/09/11/debugging-optimized-codenew-in-visual-studio-2012/ [^]

this simple patch add the switch to all projects if the compiler is > 1600

--- a\share\cmake-3.0\Modules/Platform/Windows-MSVC.cmake
+++ b\share\cmake-3.0\Modules/Platform/Windows-MSVC.cmake
@@ -254,6 +257,11 @@
   set(CMAKE_${lang}_FLAGS_INIT "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS /W3${_FLAGS_${lang}}")
   set(CMAKE_${lang}_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od ${_RTC1}")
   set(CMAKE_${lang}_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG")
   set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG")
   set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG")
+ if(MSVC_VERSION GREATER 1600)
+ set(CMAKE_${lang}_FLAGS_DEBUG_INIT "${CMAKE_${lang}_FLAGS_DEBUG_INIT} /d2Zi+")
+ set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "${CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT} /d2Zi+")
+ endif()
+
 endmacro()
No tags attached.
Issue History
2014-07-10 12:13Gunnar RothNew Issue
2014-07-10 15:23Brad KingNote Added: 0036347
2014-07-10 15:56Gunnar RothNote Added: 0036348
2014-07-14 13:30Brad KingNote Added: 0036374
2014-07-14 13:31Brad KingNote Edited: 0036347bug_revision_view_page.php?bugnote_id=36347#r1518
2014-07-15 03:31Gunnar RothNote Added: 0036385
2014-07-15 09:17Brad KingNote Added: 0036395
2016-06-10 14:29Kitware RobotNote Added: 0042583
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0036347)
Brad King   
2014-07-10 15:23   
(edited on: 2014-07-14 13:31)
Neat. According to the article you linked the feature is not documented until VS 2013 Update 3, where it is called "/Z0".

I'd rather not enable an undocumented feature by default or change existing default behavior. Applications can add the flag themselves if they want it.

Perhaps we can add /Z0 by default starting with the VS 14 support since that is new and the option should be officially documented.

If the purpose of this is to improve support in release builds, why does your patch modify _DEBUG_ and not _RELEASE_?

(0036348)
Gunnar Roth   
2014-07-10 15:56   
Actually the patch adds it for debug and relwithdebinfo.
Well for vs12 it works and this will no more be updated by Ms. I also don't think it will be removed in vs13. Doing it in your own project can be quite tedious if there are a large number of independent projects. I also would have to modify 3rd party projects just for this, wich I can just solve with 5 lines in the win32-msvc.cmake file.
(0036374)
Brad King   
2014-07-14 13:30   
According to the VS 2013 Update 3 notes:

 http://www.visualstudio.com/news/2014-jul-2-vs#C++ [^]
 /Z0 is a compiler switch that generates richer debugging information for optimized code (non /Od builds).

Since _DEBUG_ uses /Od the new /Z0 option makes sense for the other configs but not _DEBUG_.

I understand that you find the flag useful, but I'm not going to force the flag on existing projects without modifying them. Then the version of CMake used could affect how their binaries turn out. We can add it for the future VS 14 (they are skipping 13 AFAICT) because CMake has not previously supported that version so there will be no change.
(0036385)
Gunnar Roth   
2014-07-15 03:31   
the binaries are not affected by this flag only the separate pdb files. ( at least that is said in my linked article in my inital post).
well i thought that would be a nice feature for cmake to give the user automatically a better debug experience even if he never heard of the vs2012 flag.
but i can easily maintain my own patch for that, thank you nevertheless.
(0036395)
Brad King   
2014-07-15 09:17   
Re 0015014:0036385: We can still do it for "NOT MSVC_VERSION LESS 1900" and use /Z0 for all the non-DEBUG configs.
(0042583)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.