ProjectExplorer: Fix autodetect of toolchains on macOS

...when not loading the iOS plugin. Fixes a condition and
lowers priority of gcc/g++ on macOS in general.
Without this patch Qt related kits had a detected g++/gcc
assigned as compiler which made the kits useless.
When loading the iOS plugin the Apple related clang is
preferred which made the issue not present by default.
Fixes execution of AutoTest and ClangTools plugin unit
tests too.

Change-Id: I7515980c0fda48c942d7f3e7cb4d8c66965a1ab3
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Christian Stenger
2023-10-13 09:35:31 +02:00
parent 483a340e73
commit 3a671c2bb9

View File

@@ -1364,7 +1364,7 @@ Toolchains GccToolChainFactory::autoDetect(const ToolchainDetector &detector) co
}, {nameFilters, QDir::Files | QDir::Executable });
// Gcc is almost never what you want on macOS, but it is by default found in /usr/bin
if (HostOsInfo::isMacHost() && detector.device->type() != Constants::DESKTOP_DEVICE_TYPE) {
if (HostOsInfo::isMacHost() && detector.device->type() == Constants::DESKTOP_DEVICE_TYPE) {
executables.removeOne(FilePath::fromPathPart(u"/usr/bin/gcc"));
executables.removeOne(FilePath::fromPathPart(u"/usr/bin/g++"));
}
@@ -1575,6 +1575,9 @@ Toolchains GccToolChainFactory::autoDetectToolChain(const ToolChainDescription &
tc->setTargetAbi(abi);
tc->setOriginalTargetTriple(detectedAbis.originalTargetTriple);
tc->setDisplayName(tc->defaultDisplayName()); // reset displayname
// lower priority of g++/gcc on macOS - usually just a frontend to clang
if (detectedSubType == GccToolChain::RealGcc && abi.binaryFormat() == Abi::MachOFormat)
tc->setPriority(ToolChain::PriorityLow);
result.append(tc);
}
return result;