From 3064f80d254fae7ce395bbd744133a53b11170f9 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 20 Aug 2013 14:59:59 -0400 Subject: VS: Generate ToolsVersion matching each VS version The MSBuild version for each Visual Studio generator isn't 4.0. With Visual Studo 2013 the ToolsVersion moved from being tied to the .NET framework and now has its own version number. --- Source/cmGlobalVisualStudio10Generator.h | 3 +++ Source/cmGlobalVisualStudio12Generator.h | 5 +++++ Source/cmVisualStudio10TargetGenerator.cxx | 32 +++++++++++++++++++----------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 0a95091..31e122e 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -81,6 +81,9 @@ public: void PathTooLong(cmTarget* target, cmSourceFile* sf, std::string const& sfRel); + + virtual const char* GetToolsVersion() { return "4.0"; } + protected: virtual const char* GetIDEVersion() { return "10.0"; } diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h index 064e310..8c8aeb1 100644 --- a/Source/cmGlobalVisualStudio12Generator.h +++ b/Source/cmGlobalVisualStudio12Generator.h @@ -31,6 +31,11 @@ public: /** TODO: VS 12 user macro support. */ virtual std::string GetUserMacrosDirectory() { return ""; } + + //in Visual Studio 2013 they detached the MSBuild tools version + //from the .Net Framework version and instead made it have it's own + //version number + virtual const char* GetToolsVersion() { return "12.0"; } protected: virtual const char* GetIDEVersion() { return "12.0"; } private: diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ea05347..a26b291 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -216,12 +216,16 @@ void cmVisualStudio10TargetGenerator::Generate() // Write the encoding header into the file char magic[] = {0xEF,0xBB, 0xBF}; this->BuildFileStream->write(magic, 3); - this->WriteString("\n",0); - this->WriteString("\n", - 0); + + //get the tools version to use + const std::string toolsVer(this->GlobalGenerator->GetToolsVersion()); + std::string project_defaults="\n"; + project_defaults.append("\n"); + this->WriteString(project_defaults.c_str(),0); + this->WriteProjectConfigurations(); this->WriteString("\n", 1); this->WriteString("", 2); @@ -716,12 +720,16 @@ void cmVisualStudio10TargetGenerator::WriteGroups() fout.write(magic, 3); cmGeneratedFileStream* save = this->BuildFileStream; this->BuildFileStream = & fout; - this->WriteString("\n" - "\n", - 0); + + //get the tools version to use + const std::string toolsVer(this->GlobalGenerator->GetToolsVersion()); + std::string project_defaults="\n"; + project_defaults.append("\n"); + this->WriteString(project_defaults.c_str(),0); + for(ToolSourceMap::const_iterator ti = this->Tools.begin(); ti != this->Tools.end(); ++ti) { -- cgit v0.12