From 09b347d0d3f5c063cd20c30be74741711830b74c Mon Sep 17 00:00:00 2001 From: David Schulz Date: Mon, 18 Sep 2023 12:46:26 +0200 Subject: [PATCH] ProjectExplorer: fix gcc toolchain detection on windows Change-Id: Ibf23eeca79389562bc38a01ca9ec7799e22787fe Reviewed-by: Reviewed-by: Christian Kandeler --- src/plugins/projectexplorer/gcctoolchain.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index 8bc6f5f6a38..2628b506d21 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -1235,8 +1235,8 @@ static FilePaths findCompilerCandidates(const ToolchainDetector &detector, << ("*-*-*-*-" + compilerName + "-[1-9]*"); // "x86_64-pc-linux-gnu-gcc-7.4.1" } - nameFilters = transform(nameFilters, - [os = device ? device->osType() : HostOsInfo::hostOs()](const QString &baseName) { + const Utils::OsType os = device ? device->osType() : HostOsInfo::hostOs(); + nameFilters = transform(nameFilters, [os](const QString &baseName) { return OsSpecificAspects::withExecutableSuffix(os, baseName); }); @@ -1269,9 +1269,11 @@ static FilePaths findCompilerCandidates(const ToolchainDetector &detector, for (const FilePath &searchPath : std::as_const(searchPaths)) { static const QRegularExpression regexp(binaryRegexp); - const auto callBack = [&compilerPaths, compilerName](const FilePath &candidate) { - if (candidate.fileName() == compilerName || regexp.match(candidate.path()).hasMatch()) + const auto callBack = [os, &compilerPaths, compilerName](const FilePath &candidate) { + if (candidate.fileName() == OsSpecificAspects::withExecutableSuffix(os, compilerName) + || regexp.match(candidate.path()).hasMatch()) { compilerPaths << candidate; + } return IterationPolicy::Continue; }; searchPath.iterateDirectory(callBack, {nameFilters, QDir::Files | QDir::Executable});