Skip to content

Commit

Permalink
Remove ToolsVersion from generated VS projects for VS >= 2013
Browse files Browse the repository at this point in the history
Before VS 2013 ToolsVersion contained a .NET version
number (e.g. "4.0"). Since VS 2013 ToolsVersion is the same as the
Visual Studio version number (e.g. "12.0"), which is also the default.

We always wrote "4.0" (except in one special case which used
"14.0"). This doesn't bother Visual Studio itself, but other tools
like PVS-Studio.

Remove the ToolsVersion attribute from generated VS projects for VS
2013 and newer.

Task-number: QTBUG-57694
Change-Id: I7a3bc4534c492e9540f6b968bee8a969980df63f
Reviewed-by: Jake Petroules <[email protected]>
Reviewed-by: Oliver Wolff <[email protected]>
Reviewed-by: Oswald Buddenhagen <[email protected]>
  • Loading branch information
jobor committed Dec 21, 2016
1 parent 5fc2337 commit 88a02c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
18 changes: 11 additions & 7 deletions qmake/generators/win32/msbuild_objectmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool)
xml << decl("1.0", "utf-8")
<< tag("Project")
<< attrTag("DefaultTargets","Build")
<< attrTag("ToolsVersion", "4.0")
<< attrTagToolsVersion(tool.Configuration)
<< attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003")
<< tag("ItemGroup")
<< attrTag("Label", "ProjectConfigurations");
Expand Down Expand Up @@ -550,7 +550,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool)

xmlFilter << decl("1.0", "utf-8")
<< tag("Project")
<< attrTag("ToolsVersion", "4.0")
<< attrTagToolsVersion(tool.Configuration)
<< attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");

xmlFilter << tag("ItemGroup");
Expand Down Expand Up @@ -603,13 +603,10 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool)

xml.setIndentString(" ");

const QString toolsVersion = (tool.SdkVersion == QLatin1String("10.0")) ? QStringLiteral("14.0")
: QStringLiteral("4.0");

xml << decl("1.0", "utf-8")
<< tag("Project")
<< attrTag("DefaultTargets","Build")
<< attrTag("ToolsVersion", toolsVersion)
<< attrTagToolsVersion(tool.SingleProjects.first().Configuration)
<< attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003")
<< tag("ItemGroup")
<< attrTag("Label", "ProjectConfigurations");
Expand Down Expand Up @@ -796,7 +793,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool)

xmlFilter << decl("1.0", "utf-8")
<< tag("Project")
<< attrTag("ToolsVersion", "4.0")
<< attrTagToolsVersion(tool.SingleProjects.first().Configuration)
<< attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");

xmlFilter << tag("ItemGroup");
Expand Down Expand Up @@ -2056,4 +2053,11 @@ QString VCXProjectWriter::generateCondition(const VCConfiguration &config)
return QStringLiteral("'$(Configuration)|$(Platform)'=='") + config.Name + QLatin1Char('\'');
}

XmlOutput::xml_output VCXProjectWriter::attrTagToolsVersion(const VCConfiguration &config)
{
if (config.CompilerVersion >= NET2013)
return noxml();
return attrTag("ToolsVersion", "4.0");
}

QT_END_NAMESPACE
1 change: 1 addition & 0 deletions qmake/generators/win32/msbuild_objectmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class VCXProjectWriter : public VCProjectWriter
bool fileAdded, bool hasCustomBuildStep);
static void outputFileConfig(XmlOutput &xml, XmlOutput &xmlFilter, const QString &fileName, const QString &filterName);
static QString generateCondition(const VCConfiguration &config);
static XmlOutput::xml_output attrTagToolsVersion(const VCConfiguration &config);

friend class XTreeNode;
friend class XFlatNode;
Expand Down

0 comments on commit 88a02c4

Please sign in to comment.