diff options
author | Oliver Wolff <oliver.wolff@qt.io> | 2020-10-26 08:52:46 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-10-27 08:19:21 +0000 |
commit | aebc0df4bd4bcf4c705302f45347db2c21ce1b24 (patch) | |
tree | b80dd3a5d3ce36be41f983deeca4ce06e288977c /mkspecs | |
parent | 28bc3ca8114033a5542e7877105de4f7ec62bf83 (diff) |
toolchain.prf: Use vswhere to obtain VS installation path
Beginning with Visual Studio 2017, vswhere should be used to discover
Visual Studio installations. Installations of 2019 and up are not even
registered inside the registry anymore, so vswhere is the only way to
obtain information about these.
Task-number: QTVSADDINBUG-819
Change-Id: Ibd8b2c4d38c7925857887f39e750e87a33f08bf9
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 04e03065203550fdc2a06070d5250f66cbff7d4b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'mkspecs')
-rw-r--r-- | mkspecs/features/toolchain.prf | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf index efbe7c1e55..11ecd6b2a5 100644 --- a/mkspecs/features/toolchain.prf +++ b/mkspecs/features/toolchain.prf @@ -326,9 +326,17 @@ isEmpty($${target_prefix}.INCDIRS) { error("Mkspec does not specify MSVC_VER. Cannot continue.") versionAtLeast(MSVC_VER, 15.0) { dir = $$(VSINSTALLDIR) - isEmpty(dir): \ - dir = $$read_registry(HKLM, \ - "Software\\Microsoft\\VisualStudio\\SxS\\VS7\\$$MSVC_VER", 32) + isEmpty(dir) { + version_parts = $$split(MSVC_VER, .) + MSVC_NEXT_MAJOR = $$num_add($$first(version_parts), 1) + vswhere = "$$getenv(ProgramFiles\(x86\))/Microsoft Visual Studio/Installer/vswhere.exe" + !exists($$vswhere): \ + error("Could not find $$vswhere") + vswhere = $$system_quote($$system_path($$vswhere)) + # -version parameter: A version range for instances to find. 15.0 will get all versions >= 15.0 + # Example: [15.0,16.0) will find versions 15.*. + dir = $$system("$$vswhere -latest -version [$$MSVC_VER,$${MSVC_NEXT_MAJOR}.0] -property installationPath") + } isEmpty(dir): \ error("Failed to find the Visual Studio installation directory.") cmd += $$system_quote($$dir\\VC\\Auxiliary\\Build\\vcvarsall.bat) $$arch |