From ffabc5dff1c32c5fd17e974722853db61acdb389 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Fri, 23 Dec 2016 00:13:28 +0200 Subject: [PATCH] QmakePM: Fix false positive warning for incompatible compiler Some users set 'QMAKE_CXX = @echo $< && $$QMAKE_CXX' to prettify the compiler output. Another useful case for "incompatible" compiler is ccache, or other compiler wrappers. To eliminate warnings for these cases, pick the last value of QMAKE_CC/ QMAKE_CXX, excluding flags, and compare it against the configured toolchain. Change-Id: Idc3b9377e6f7c39c09c50f36ec89460756510b97 Reviewed-by: Oswald Buddenhagen Reviewed-by: Tobias Hunger --- src/plugins/qmakeprojectmanager/qmakeproject.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp index 8be3ff5c5a9..7f281b81dde 100644 --- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp @@ -1532,8 +1532,17 @@ bool QmakeProject::matchesKit(const Kit *kit) return false; } -static Utils::FileName getFullPathOf(const QString &exe, const BuildConfiguration *bc) +static Utils::FileName getFullPathOf(const QmakeProFileNode *pro, QmakeVariable variable, + const BuildConfiguration *bc) { + // Take last non-flag value, to cover e.g. '@echo $< && $$QMAKE_CC' or 'ccache gcc' + const QStringList values = Utils::filtered(pro->variableValue(variable), + [](const QString &value) { + return !value.startsWith('-'); + }); + if (values.isEmpty()) + return Utils::FileName(); + const QString exe = values.last(); QTC_ASSERT(bc, return Utils::FileName::fromString(exe)); QFileInfo fi(exe); if (fi.isAbsolute()) @@ -1572,9 +1581,9 @@ void QmakeProject::warnOnToolChainMismatch(const QmakeProFileNode *pro) const return; testToolChain(ToolChainKitInformation::toolChain(t->kit(), ToolChain::Language::C), - getFullPathOf(pro->singleVariableValue(QmakeCc), bc)); + getFullPathOf(pro, QmakeCc, bc)); testToolChain(ToolChainKitInformation::toolChain(t->kit(), ToolChain::Language::Cxx), - getFullPathOf(pro->singleVariableValue(QmakeCxx), bc)); + getFullPathOf(pro, QmakeCxx, bc)); } QString QmakeProject::executableFor(const QmakeProFileNode *node)