Skip to content

VS: Fix GenerateDebugInformation values for v140 and v141 toolsets

Ian Hojnicki requested to merge ihojnicki/cmake:vs_generate_dgb_info into master

When VS 2015 was first released, its new v140 toolset came with a link.xml file that changed the GenerateDebugInformation boolean (false and true) value from earlier toolsets to an enumeration consisting of the possible values No, Debug, and DebugFastLink.

We first adapted to this in commit f086c665, but that broke older toolsets that still expected the boolean. Then commit dc422d27 added a hack to fix up the value based on the toolset in use. Several follow-up commits fixed this for more older toolsets because our flag table was at the time based on the generator in use rather than the toolset in use.

Since !73 (merged) we use a flag table based on the toolset, so the fixup hack should not be needed. We had to keep it around only due to our default value for GenerateDebugInformation (false or No) still being based on the generator instead of the toolset.

A VS 2015 update was released that changed the v140 toolset link.xml file back to using false and true for the GenerateDebugInformation enumeration variants previously known as No and Debug. In order to know which pair to use, we need to parse the link.xml file for the current toolset.

Switch back to using false and true unconditionally in our GenerateDebugInformation flag table entries and default value. With that plus the toolset-based flag table, we now get incorrect values for GenerateDebugInformation only when using a v140 toolset from an older VS 2015 installation. Detect this case by parsing link.xml and add special logic to convert false and true to No and Debug to satisfy the older toolset specification.

The original description of this MR follows.

Simplified example:

project(Sample NONE)
     "Release configuration linker flags")
enable_language(CXX C)
add_executable(Sample sample.cpp)

Open the resulting project in VS2015/VS2017 and look at Linker > Debugging > Generate Debug Info. It will be say "Debug" instead of "Generate Debug Information (/DEBUG)".

Topic-rename: vs-link-debug-flags

Edited by Brad King

Merge request reports