diff options
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 19 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.h | 9 | ||||
-rw-r--r-- | Source/cmVS140LinkFlagTable.h | 2 | ||||
-rw-r--r-- | Source/cmVS141LinkFlagTable.h | 2 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 37 |
5 files changed, 39 insertions, 30 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 0e02b0a..e3835ff 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -130,6 +130,7 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( this->DefaultNasmFlagTable = cmVS10NASMFlagTable; this->DefaultRcFlagTable = cmVS10RCFlagTable; this->Version = VS10; + this->PlatformToolsetNeedsDebugEnum = false; } bool cmGlobalVisualStudio10Generator::MatchesGeneratorName( @@ -195,6 +196,24 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset( return false; } + if (cmHasLiteralPrefix(this->GetPlatformToolsetString(), "v140")) { + // The GenerateDebugInformation link setting for the v140 toolset + // in VS 2015 was originally an enum with "No" and "Debug" values, + // differing from the "false" and "true" values used in older toolsets. + // A VS 2015 update changed it back. Parse the "link.xml" file to + // discover which one we need. + std::string const link_xml = this->VCTargetsPath + "/1033/link.xml"; + cmsys::ifstream fin(link_xml.c_str()); + std::string line; + while (fin && cmSystemTools::GetLineFromStream(fin, line)) { + if (line.find(" Switch=\"DEBUG\" ") != std::string::npos) { + this->PlatformToolsetNeedsDebugEnum = + line.find(" Name=\"Debug\" ") != std::string::npos; + break; + } + } + } + if (this->GeneratorToolsetCuda.empty()) { // Find the highest available version of the CUDA tools. std::vector<std::string> cudaTools; diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 20f992a..4a5c245 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -59,6 +59,13 @@ public: const char* GetPlatformToolsetCuda() const; std::string const& GetPlatformToolsetCudaString() const; + /** Return whether we need to use No/Debug instead of false/true + for GenerateDebugInformation. */ + bool GetPlatformToolsetNeedsDebugEnum() const + { + return this->PlatformToolsetNeedsDebugEnum; + } + /** Return the CMAKE_SYSTEM_NAME. */ std::string const& GetSystemName() const { return this->SystemName; } @@ -169,6 +176,8 @@ private: virtual std::string FindDevEnvCommand(); virtual std::string GetVSMakeProgram() { return this->GetMSBuildCommand(); } + bool PlatformToolsetNeedsDebugEnum; + bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf); std::string VCTargetsPath; diff --git a/Source/cmVS140LinkFlagTable.h b/Source/cmVS140LinkFlagTable.h index 618087a..613541c 100644 --- a/Source/cmVS140LinkFlagTable.h +++ b/Source/cmVS140LinkFlagTable.h @@ -38,7 +38,7 @@ static cmVS7FlagTable cmVS140LinkFlagTable[] = { { "GenerateDebugInformation", "DEBUG:FASTLINK", "Optimize for faster linking", "DebugFastLink", cmVS7FlagTable::CaseInsensitive }, - { "GenerateDebugInformation", "DEBUG", "Optimize for debugging", "Debug", + { "GenerateDebugInformation", "DEBUG", "Optimize for debugging", "true", cmVS7FlagTable::CaseInsensitive }, { "SubSystem", "", "Not Set", "NotSet", 0 }, diff --git a/Source/cmVS141LinkFlagTable.h b/Source/cmVS141LinkFlagTable.h index e707b90..ff0c1da 100644 --- a/Source/cmVS141LinkFlagTable.h +++ b/Source/cmVS141LinkFlagTable.h @@ -38,7 +38,7 @@ static cmVS7FlagTable cmVS141LinkFlagTable[] = { { "GenerateDebugInformation", "DEBUG:FASTLINK", "Generate Debug Information optimized for faster links", "DebugFastLink", cmVS7FlagTable::CaseInsensitive }, - { "GenerateDebugInformation", "DEBUG", "Generate Debug Information", "Debug", + { "GenerateDebugInformation", "DEBUG", "Generate Debug Information", "true", cmVS7FlagTable::CaseInsensitive }, { "SubSystem", "", "Not Set", "NotSet", 0 }, diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index de1f5b0..88fa19c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -17,8 +17,6 @@ #include "cm_auto_ptr.hxx" -static std::string const kWINDOWS_7_1_SDK = "Windows7.1SDK"; - static std::string cmVS10EscapeXML(std::string arg) { cmSystemTools::ReplaceString(arg, "&", "&"); @@ -3130,12 +3128,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( linkOptions.AddFlag("StackReserveSize", stackVal); } - if (this->LocalGenerator->GetVersion() >= - cmGlobalVisualStudioGenerator::VS14) { - linkOptions.AddFlag("GenerateDebugInformation", "No"); - } else { - linkOptions.AddFlag("GenerateDebugInformation", "false"); - } + linkOptions.AddFlag("GenerateDebugInformation", "false"); std::string pdb = this->GeneratorTarget->GetPDBDirectory(config.c_str()); pdb += "/"; @@ -3182,26 +3175,14 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( "%(IgnoreSpecificDefaultLibraries)"); } - // Hack to fix flag version selection in a common use case. - // FIXME: Select flag table based on toolset instead of VS version. - if (this->LocalGenerator->GetVersion() >= - cmGlobalVisualStudioGenerator::VS14) { - const char* toolset = gg->GetPlatformToolset(); - if (toolset && - (toolset == kWINDOWS_7_1_SDK || /* clang-format please break here */ - cmHasLiteralPrefix(toolset, "v80") || - cmHasLiteralPrefix(toolset, "v90") || - cmHasLiteralPrefix(toolset, "v100") || - cmHasLiteralPrefix(toolset, "v110") || - cmHasLiteralPrefix(toolset, "v120"))) { - if (const char* debug = - linkOptions.GetFlag("GenerateDebugInformation")) { - // Convert value from enumeration back to boolean for older toolsets. - if (strcmp(debug, "No") == 0) { - linkOptions.AddFlag("GenerateDebugInformation", "false"); - } else if (strcmp(debug, "Debug") == 0) { - linkOptions.AddFlag("GenerateDebugInformation", "true"); - } + // VS 2015 without all updates has a v140 toolset whose + // GenerateDebugInformation expects No/Debug instead of false/true. + if (gg->GetPlatformToolsetNeedsDebugEnum()) { + if (const char* debug = linkOptions.GetFlag("GenerateDebugInformation")) { + if (strcmp(debug, "false") == 0) { + linkOptions.AddFlag("GenerateDebugInformation", "No"); + } else if (strcmp(debug, "true") == 0) { + linkOptions.AddFlag("GenerateDebugInformation", "Debug"); } } } |