From 6c40fec9b0f11178ee987313c8a16af5a7b57c90 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 12 Aug 2019 15:29:33 +0200 Subject: [PATCH] QmakeProjectManager: Try harder to find include paths in sysroot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As opposed to qmake itself, Qt Creator tries to resolve the value of INCLUDEPATH against the sysroot. Therefore we should not reject Unix- type absolute paths as candidates for sysrootification on Windows hosts. Fixes: QTCREATORBUG-21164 Change-Id: If4be103061ad3edc64f8d1f5cfeb7c6b48e961c8 Reviewed-by: Jörg Bornemann --- .../qmakeprojectmanager/qmakeparsernodes.cpp | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp b/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp index e09cbba9d8d..b361b5f104a 100644 --- a/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp @@ -1785,11 +1785,30 @@ QStringList QmakeProFile::includePaths(QtSupport::ProFileReader *reader, const F } } + bool tryUnfixified = false; foreach (const ProFileEvaluator::SourceFile &el, reader->fixifiedValues(QLatin1String("INCLUDEPATH"), projectDir, buildDir.toString(), false)) { - paths << sysrootify(el.fileName, sysroot.toString(), projectDir, buildDir.toString()); + const QString sysrootifiedPath = sysrootify(el.fileName, sysroot.toString(), projectDir, + buildDir.toString()); + if (IoUtils::exists(sysrootifiedPath)) + paths << sysrootifiedPath; + else + tryUnfixified = true; } + + // If sysrootifying a fixified path does not yield a valid path, try again with the + // unfixified value. This can be necessary for cross-building; see QTCREATORBUG-21164. + if (tryUnfixified) { + const QStringList rawValues = reader->values("INCLUDEPATH"); + for (const QString &p : rawValues) { + const QString sysrootifiedPath = sysrootify(QDir::cleanPath(p), sysroot.toString(), + projectDir, buildDir.toString()); + if (IoUtils::exists(sysrootifiedPath)) + paths << sysrootifiedPath; + } + } + // paths already contains moc dir and ui dir, due to corrrectly parsing uic.prf and moc.prf // except if those directories don't exist at the time of parsing // thus we add those directories manually (without checking for existence)