Set WindowsTargetPlatform[Min]Version if WindowsSDKVersion is set

This fixes qmake-generated project files for Visual Studio 2017 for
setups where the Windows 8.1 SDK is not installed.

Task-number: QTBUG-66265
Change-Id: I67712019f7142e40262f171eb23f9f1e6ab3a251
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Miguel Costa <miguel.costa@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Joerg Bornemann 2018-02-19 12:18:57 +01:00
parent b32d16d468
commit 0ee5cbb1a4

View File

@ -34,6 +34,7 @@
#include <qscopedpointer.h>
#include <qstringlist.h>
#include <qfileinfo.h>
#include <qversionnumber.h>
QT_BEGIN_NAMESPACE
@ -618,17 +619,30 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool)
<< tagValue("RootNamespace", tool.Name)
<< tagValue("Keyword", tool.Keyword);
QString windowsTargetPlatformVersion;
if (isWinRT) {
xml << tagValue("MinimumVisualStudioVersion", tool.Version)
<< tagValue("DefaultLanguage", "en")
<< tagValue("AppContainerApplication", "true")
<< tagValue("ApplicationType", "Windows Store")
<< tagValue("ApplicationTypeRevision", tool.SdkVersion);
if (tool.SdkVersion == "10.0") {
const QString ucrtVersion = qgetenv("UCRTVERSION");
xml << tagValue("WindowsTargetPlatformVersion", ucrtVersion)
<< tagValue("WindowsTargetPlatformMinVersion", ucrtVersion);
}
if (tool.SdkVersion == "10.0")
windowsTargetPlatformVersion = qgetenv("UCRTVERSION");
} else {
QByteArray winSDKVersionStr = qgetenv("WindowsSDKVersion").trimmed();
// This environment variable might end with a backslash due to a VS bug.
if (winSDKVersionStr.endsWith('\\'))
winSDKVersionStr.chop(1);
QVersionNumber winSDKVersion = QVersionNumber::fromString(
QString::fromLocal8Bit(winSDKVersionStr));
if (!winSDKVersion.isNull())
windowsTargetPlatformVersion = winSDKVersionStr;
}
if (!windowsTargetPlatformVersion.isEmpty()) {
xml << tagValue("WindowsTargetPlatformVersion", windowsTargetPlatformVersion)
<< tagValue("WindowsTargetPlatformMinVersion", windowsTargetPlatformVersion);
}
xml << closetag();