From 6e5c72824af64fbcd133b28b9a76a7eaee4e3468 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 15 Feb 2024 15:01:16 +0100 Subject: QmakeProjectManager: Fix Makefile compatibility check E.g. qmake "binaries" for Android are actually shell scripts that call a Desktop qmake in a different location, which lead Qt Creator to conclude that the directory contains an incompatible build. Fix this by checking that the -qtconf argument passed to qmake points into the real qmake's parent directory, as is the case in the abovementioned scenario. Fixes: QTCREATORBUG-30354 Change-Id: Id6e878fab3379a3a8893389447514a1b7226784c Reviewed-by: Reviewed-by: Alessandro Portale Reviewed-by: Qt CI Bot --- src/plugins/qmakeprojectmanager/makefileparse.cpp | 8 ++++++++ src/plugins/qmakeprojectmanager/makefileparse.h | 2 ++ src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp | 4 +++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmakeprojectmanager/makefileparse.cpp b/src/plugins/qmakeprojectmanager/makefileparse.cpp index 60a04cee0a..9d2bda465f 100644 --- a/src/plugins/qmakeprojectmanager/makefileparse.cpp +++ b/src/plugins/qmakeprojectmanager/makefileparse.cpp @@ -56,6 +56,7 @@ void MakeFileParse::parseArgs(const QString &args, const QString &project, static const QRegularExpression regExp(QLatin1String("^([^\\s\\+-]*)\\s*(\\+=|=|-=|~=)(.*)$")); bool after = false; bool ignoreNext = false; + bool nextIsQtConfArg = false; m_unparsedArguments = args; ProcessArgs::ArgIterator ait(&m_unparsedArguments); while (ait.next()) { @@ -63,11 +64,18 @@ void MakeFileParse::parseArgs(const QString &args, const QString &project, // Ignoring ignoreNext = false; ait.deleteArg(); + } else if (nextIsQtConfArg) { + nextIsQtConfArg = false; + m_qtConfFile = FilePath::fromUserInput(ait.value()); + ait.deleteArg(); } else if (ait.value() == project) { ait.deleteArg(); } else if (ait.value() == QLatin1String("-after")) { after = true; ait.deleteArg(); + } else if (ait.value() == "-qtconf") { + nextIsQtConfArg = true; + ait.deleteArg(); } else if (ait.value().contains(QLatin1Char('='))) { const QRegularExpressionMatch match = regExp.match(ait.value()); if (match.hasMatch()) { diff --git a/src/plugins/qmakeprojectmanager/makefileparse.h b/src/plugins/qmakeprojectmanager/makefileparse.h index e9e5be0812..18be3f801a 100644 --- a/src/plugins/qmakeprojectmanager/makefileparse.h +++ b/src/plugins/qmakeprojectmanager/makefileparse.h @@ -30,6 +30,7 @@ public: MakefileState makeFileState() const; Utils::FilePath qmakePath() const; Utils::FilePath srcProFile() const; + Utils::FilePath qtConfPath() const { return m_qtConfFile;} QMakeStepConfig config() const; QString unparsedArguments() const; @@ -59,6 +60,7 @@ private: MakefileState m_state; Utils::FilePath m_qmakePath; Utils::FilePath m_srcProFile; + Utils::FilePath m_qtConfFile; QmakeBuildConfig m_qmakeBuildConfig; QMakeStepConfig m_config; diff --git a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp index 798eae306f..f3a71728d0 100644 --- a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp +++ b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp @@ -490,7 +490,9 @@ QmakeBuildConfiguration::MakefileState QmakeBuildConfiguration::compareToImportF return MakefileIncompatible; } - if (version->qmakeFilePath() != parse.qmakePath()) { + if (version->qmakeFilePath() != parse.qmakePath() + && (parse.qtConfPath().isEmpty() // QTCREATORBUG-30354 + || version->qmakeFilePath().parentDir() != parse.qtConfPath().parentDir())) { qCDebug(logs) << "**Different Qt versions, buildconfiguration:" << version->qmakeFilePath() << " Makefile:" << parse.qmakePath(); return MakefileForWrongProject; -- cgit v1.2.3