aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmakeprojectmanager/qmakekitinformation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/qmakeprojectmanager/qmakekitinformation.cpp')
-rw-r--r--src/plugins/qmakeprojectmanager/qmakekitinformation.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/plugins/qmakeprojectmanager/qmakekitinformation.cpp b/src/plugins/qmakeprojectmanager/qmakekitinformation.cpp
index 57550e2e52..5e1244768a 100644
--- a/src/plugins/qmakeprojectmanager/qmakekitinformation.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakekitinformation.cpp
@@ -92,11 +92,23 @@ void QmakeKitInformation::setup(Kit *k)
&& version->qtAbis().contains(t->targetAbi());
});
if (!possibleTcs.isEmpty()) {
- ToolChain *possibleTc
- = Utils::findOr(possibleTcs, possibleTcs.last(),
- [&spec](const ToolChain *t) { return t->suggestedMkspecList().contains(spec); });
- if (possibleTc)
- ToolChainKitInformation::setAllToolChainsToMatch(k, possibleTc);
+ const QList<ToolChain *> goodTcs = Utils::filtered(possibleTcs,
+ [&spec](const ToolChain *t) {
+ return t->suggestedMkspecList().contains(spec);
+ });
+ // Hack to prefer a tool chain from PATH (e.g. autodetected) over other matches.
+ // This improves the situation a bit if a cross-compilation tool chain has the
+ // same ABI as the host.
+ const Environment systemEnvironment = Environment::systemEnvironment();
+ ToolChain *bestTc = Utils::findOrDefault(goodTcs,
+ [&systemEnvironment](const ToolChain *t) {
+ return systemEnvironment.path().contains(t->compilerCommand().parentDir().toString());
+ });
+ if (!bestTc) {
+ bestTc = goodTcs.isEmpty() ? possibleTcs.last() : goodTcs.last();
+ }
+ if (bestTc)
+ ToolChainKitInformation::setAllToolChainsToMatch(k, bestTc);
}
}
}