From 89a02029b87c4c94afe932a5d0df709d69b5acf9 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 27 Nov 2019 18:03:52 +0100 Subject: [PATCH] CMakeProjectManager: Make search for CMake in "ProgramFiles" more robust Also search in "ProgramW6432", so that a 32-bit Qt Creator on a 64-bit Windows can find a 64-bit CMake installation. Change-Id: Ia02a8a3e2308fa0dfb422df6969c8313868d3ce6 Reviewed-by: Cristian Adam Reviewed-by: Eike Ziller Reviewed-by: Tobias Hunger Reviewed-by: Christian Stenger --- .../cmaketoolsettingsaccessor.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmaketoolsettingsaccessor.cpp b/src/plugins/cmakeprojectmanager/cmaketoolsettingsaccessor.cpp index b126ded5f7c..cd4f5d49769 100644 --- a/src/plugins/cmakeprojectmanager/cmaketoolsettingsaccessor.cpp +++ b/src/plugins/cmakeprojectmanager/cmaketoolsettingsaccessor.cpp @@ -76,13 +76,12 @@ static std::vector> autoDetectCMakeTools() path = Utils::filteredUnique(path); if (HostOsInfo::isWindowsHost()) { - const QString progFiles = QLatin1String(qgetenv("ProgramFiles")); - path.append(Utils::FilePath::fromString(progFiles + "/CMake")); - path.append(Utils::FilePath::fromString(progFiles + "/CMake/bin")); - const QString progFilesX86 = QLatin1String(qgetenv("ProgramFiles(x86)")); - if (!progFilesX86.isEmpty()) { - path.append(Utils::FilePath::fromString(progFilesX86 + "/CMake")); - path.append(Utils::FilePath::fromString(progFilesX86 + "/CMake/bin")); + for (auto envVar : {"ProgramFiles", "ProgramFiles(x86)", "ProgramW6432"}) { + if (qEnvironmentVariableIsSet(envVar)) { + const QString progFiles = qEnvironmentVariable(envVar); + path.append(Utils::FilePath::fromString(progFiles + "/CMake")); + path.append(Utils::FilePath::fromString(progFiles + "/CMake/bin")); + } } }