From 0ee5cbb1a449e05270454dfb6151438b04a5cb84 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 19 Feb 2018 12:18:57 +0100 Subject: 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 Reviewed-by: Miguel Costa Reviewed-by: Joerg Bornemann --- qmake/generators/win32/msbuild_objectmodel.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'qmake/generators') diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index 38bf3a0cbd..9f82ce4f8e 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -34,6 +34,7 @@ #include #include #include +#include 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(); -- cgit v1.2.3