From 07ee43142bca89958567af55d843e8920c644d35 Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Thu, 24 Oct 2013 20:14:10 +0300 Subject: [PATCH] qmake: Support MSVC2013 for WinRT builds Change-Id: I1c102f0b029616997d72933a90c0f9a2a3a9e222 Reviewed-by: Oswald Buddenhagen Reviewed-by: Oliver Wolff --- mkspecs/winphone-arm-msvc2012/qmake.conf | 3 ++ mkspecs/winphone-x86-msvc2012/qmake.conf | 3 ++ mkspecs/winrt-arm-msvc2012/qmake.conf | 3 ++ mkspecs/winrt-arm-msvc2013/qmake.conf | 3 ++ mkspecs/winrt-x64-msvc2012/qmake.conf | 3 ++ mkspecs/winrt-x64-msvc2013/qmake.conf | 3 ++ mkspecs/winrt-x86-msvc2012/qmake.conf | 3 ++ mkspecs/winrt-x86-msvc2013/qmake.conf | 3 ++ qmake/generators/win32/msvc_nmake.cpp | 66 +++++++++++++++--------- 9 files changed, 65 insertions(+), 25 deletions(-) diff --git a/mkspecs/winphone-arm-msvc2012/qmake.conf b/mkspecs/winphone-arm-msvc2012/qmake.conf index 54f96e6709..d5d26d2a96 100644 --- a/mkspecs/winphone-arm-msvc2012/qmake.conf +++ b/mkspecs/winphone-arm-msvc2012/qmake.conf @@ -14,3 +14,6 @@ QMAKE_LFLAGS += /MACHINE:ARM QMAKE_LIBS += WindowsPhoneCore.lib PhoneAppModelHost.lib ws2_32.lib VCPROJ_ARCH = ARM +MSVC_VER = 11.0 +WINSDK_VER = 8.0 +WINTARGET_VER = WP80 diff --git a/mkspecs/winphone-x86-msvc2012/qmake.conf b/mkspecs/winphone-x86-msvc2012/qmake.conf index ede9bb59be..59e6fb45db 100644 --- a/mkspecs/winphone-x86-msvc2012/qmake.conf +++ b/mkspecs/winphone-x86-msvc2012/qmake.conf @@ -14,3 +14,6 @@ QMAKE_LFLAGS += /MACHINE:X86 QMAKE_LIBS += WindowsPhoneCore.lib PhoneAppModelHost.lib ws2_32.lib VCPROJ_ARCH = x86 +MSVC_VER = 11.0 +WINSDK_VER = 8.0 +WINTARGET_VER = WP80 diff --git a/mkspecs/winrt-arm-msvc2012/qmake.conf b/mkspecs/winrt-arm-msvc2012/qmake.conf index 7abca86511..951dc2db35 100644 --- a/mkspecs/winrt-arm-msvc2012/qmake.conf +++ b/mkspecs/winrt-arm-msvc2012/qmake.conf @@ -13,3 +13,6 @@ QMAKE_LFLAGS += /MACHINE:ARM QMAKE_LIBS += windowscodecs.lib kernel32.lib ole32.lib VCPROJ_ARCH = ARM +MSVC_VER = 11.0 +WINSDK_VER = 8.0 +WINTARGET_VER = win8 diff --git a/mkspecs/winrt-arm-msvc2013/qmake.conf b/mkspecs/winrt-arm-msvc2013/qmake.conf index 2fd326de24..5527a7a41c 100644 --- a/mkspecs/winrt-arm-msvc2013/qmake.conf +++ b/mkspecs/winrt-arm-msvc2013/qmake.conf @@ -15,3 +15,6 @@ QMAKE_LFLAGS += /MACHINE:ARM QMAKE_LIBS += windowscodecs.lib kernel32.lib ole32.lib VCPROJ_ARCH = ARM +MSVC_VER = 12.0 +WINSDK_VER = 8.1 +WINTARGET_VER = winv6.3 diff --git a/mkspecs/winrt-x64-msvc2012/qmake.conf b/mkspecs/winrt-x64-msvc2012/qmake.conf index c5efcc5481..96806499bc 100644 --- a/mkspecs/winrt-x64-msvc2012/qmake.conf +++ b/mkspecs/winrt-x64-msvc2012/qmake.conf @@ -13,3 +13,6 @@ QMAKE_LFLAGS += /MACHINE:X64 QMAKE_LIBS += windowscodecs.lib kernel32.lib ole32.lib VCPROJ_ARCH = x64 +MSVC_VER = 11.0 +WINSDK_VER = 8.0 +WINTARGET_VER = win8 diff --git a/mkspecs/winrt-x64-msvc2013/qmake.conf b/mkspecs/winrt-x64-msvc2013/qmake.conf index 417cb0f1a0..e7d2432cc4 100644 --- a/mkspecs/winrt-x64-msvc2013/qmake.conf +++ b/mkspecs/winrt-x64-msvc2013/qmake.conf @@ -15,3 +15,6 @@ QMAKE_LFLAGS += /MACHINE:X64 QMAKE_LIBS += windowscodecs.lib kernel32.lib ole32.lib VCPROJ_ARCH = x64 +MSVC_VER = 12.0 +WINSDK_VER = 8.1 +WINTARGET_VER = winv6.3 diff --git a/mkspecs/winrt-x86-msvc2012/qmake.conf b/mkspecs/winrt-x86-msvc2012/qmake.conf index 7c0522adb7..b0d9017ebb 100644 --- a/mkspecs/winrt-x86-msvc2012/qmake.conf +++ b/mkspecs/winrt-x86-msvc2012/qmake.conf @@ -13,3 +13,6 @@ QMAKE_LFLAGS += /MACHINE:X86 QMAKE_LIBS += windowscodecs.lib kernel32.lib ole32.lib VCPROJ_ARCH = x86 +MSVC_VER = 11.0 +WINSDK_VER = 8.0 +WINTARGET_VER = win8 diff --git a/mkspecs/winrt-x86-msvc2013/qmake.conf b/mkspecs/winrt-x86-msvc2013/qmake.conf index 075067c04e..40fd339b5b 100644 --- a/mkspecs/winrt-x86-msvc2013/qmake.conf +++ b/mkspecs/winrt-x86-msvc2013/qmake.conf @@ -15,3 +15,6 @@ QMAKE_LFLAGS += /MACHINE:X86 QMAKE_LIBS += windowscodecs.lib kernel32.lib ole32.lib VCPROJ_ARCH = x86 +MSVC_VER = 12.0 +WINSDK_VER = 8.1 +WINTARGET_VER = winv6.3 diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index 3185e68ecc..4412a131ad 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -126,24 +126,56 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t) compiler = QStringLiteral("x86_amd64"); compilerArch = QStringLiteral("amd64"); } -#ifdef Q_OS_WIN64 - const QString regKey = QStringLiteral("Software\\Wow6432Node\\Microsoft\\VisualStudio\\11.0\\Setup\\VC\\ProductDir"); -#else - const QString regKey = QStringLiteral("Software\\Microsoft\\VisualStudio\\11.0\\Setup\\VC\\ProductDir"); + + const QString msvcVer = project->first("MSVC_VER").toQString(); + if (msvcVer.isEmpty()) { + fprintf(stderr, "Mkspec does not specify MSVC_VER. Cannot continue.\n"); + return false; + } + const QString winsdkVer = project->first("WINSDK_VER").toQString(); + if (winsdkVer.isEmpty()) { + fprintf(stderr, "Mkspec does not specify WINSDK_VER. Cannot continue.\n"); + return false; + } + const QString targetVer = project->first("WINTARGET_VER").toQString(); + if (targetVer.isEmpty()) { + fprintf(stderr, "Mkspec does not specify WINTARGET_VER. Cannot continue.\n"); + return false; + } + + QString regKeyPrefix; +#if !defined(Q_OS_WIN64) && _WIN32_WINNT >= 0x0501 + BOOL isWow64; + IsWow64Process(GetCurrentProcess(), &isWow64); + if (!isWow64) + regKeyPrefix = QStringLiteral("Software\\"); + else #endif + regKeyPrefix = QStringLiteral("Software\\Wow6432Node\\"); + + QString regKey = regKeyPrefix + QStringLiteral("Microsoft\\VisualStudio\\") + msvcVer + ("\\Setup\\VC\\ProductDir"); const QString vcInstallDir = qt_readRegistryKey(HKEY_LOCAL_MACHINE, regKey); if (vcInstallDir.isEmpty()) { - fprintf(stderr, "Failed to find the Visual Studio 2012 installation directory.\n" - "Is it installed?.\n"); + fprintf(stderr, "Failed to find the Visual Studio installation directory.\n"); + return false; + } + + const bool isPhone = project->isActiveConfig(QStringLiteral("winphone")); + regKey = regKeyPrefix + + (isPhone ? QStringLiteral("Microsoft\\Microsoft SDKs\\WindowsPhone\\v") + : QStringLiteral("Microsoft\\Microsoft SDKs\\Windows\\v")) + + winsdkVer + QStringLiteral("\\InstallationFolder"); + const QString kitDir = qt_readRegistryKey(HKEY_LOCAL_MACHINE, regKey); + if (kitDir.isEmpty()) { + fprintf(stderr, "Failed to find the Windows Kit installation directory.\n"); return false; } QStringList incDirs; QStringList libDirs; QStringList binDirs; - const bool isPhone = project->isActiveConfig(QStringLiteral("winphone")); if (isPhone) { - QString sdkDir = vcInstallDir + QStringLiteral("/WPSDK/WP80"); + QString sdkDir = vcInstallDir + QStringLiteral("/WPSDK/") + targetVer; if (!QDir(sdkDir).exists()) { fprintf(stderr, "Failed to find the Windows Phone SDK in %s.\n" "Check that it is properly installed.\n", @@ -153,14 +185,6 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t) incDirs << sdkDir + QStringLiteral("/include"); libDirs << sdkDir + QStringLiteral("/lib/") + compilerArch; binDirs << sdkDir + QStringLiteral("/bin/") + compiler; - - QString kitDir = vcInstallDir + QStringLiteral("/../../Windows Phone Kits/8.0"); - if (!QDir(kitDir).exists()) { - fprintf(stderr, "Failed to find the Windows Phone Kit in %s.\n" - "Check that it is properly installed.\n", - qPrintable(QDir::toNativeSeparators(kitDir))); - return false; - } libDirs << kitDir + QStringLiteral("/lib/") + arch; incDirs << kitDir + QStringLiteral("/include") << kitDir + QStringLiteral("/include/abi") @@ -171,15 +195,7 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t) libDirs << vcInstallDir + QStringLiteral("/lib/") + compilerArch; binDirs << vcInstallDir + QStringLiteral("/bin/") + compiler << vcInstallDir + QStringLiteral("/../Common7/IDE"); - - QString kitDir = vcInstallDir + QStringLiteral("/../../Windows Kits/8.0"); - if (!QDir(kitDir).exists()) { - fprintf(stderr, "Failed to find the Windows Kit in %s.\n" - "Check that it is properly installed.\n", - qPrintable(QDir::toNativeSeparators(kitDir))); - return false; - } - libDirs << kitDir + QStringLiteral("/Lib/win8/um/") + arch; + libDirs << kitDir + QStringLiteral("/Lib/") + targetVer + ("/um/") + arch; incDirs << kitDir + QStringLiteral("/include/um") << kitDir + QStringLiteral("/include/shared") << kitDir + QStringLiteral("/include/winrt");