forked from qt-creator/qt-creator
CMake: Work around cmake reporting include paths in random order
Work around cmake reporting include paths in random order to Qt Creator due to a bug in the CodeBlocks generator. Remove the tool chains include paths from the list reported by cmake and have the code model add those again later. That keeps at least the include paths of the compiler in order, which is important as this makes sure any fixed headers shipped with the compiler actually get picked up. Task-number: QTCREATORBUG-16432 Change-Id: I218735914bcc750ce87b02b05d111f3fe2bb5644 Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
@@ -66,6 +66,7 @@
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QSet>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
@@ -242,15 +243,27 @@ void CMakeProject::parseCMakeOutput()
|
||||
activeQtVersion = CppTools::ProjectPart::Qt5;
|
||||
}
|
||||
|
||||
const Utils::FileName sysroot = ProjectExplorer::SysRootKitInformation::sysRoot(k);
|
||||
|
||||
ppBuilder.setQtVersion(activeQtVersion);
|
||||
|
||||
QHash<QString, QStringList> targetDataCache;
|
||||
foreach (const CMakeBuildTarget &cbt, buildTargets()) {
|
||||
// This explicitly adds -I. to the include paths
|
||||
QStringList includePaths = cbt.includeFiles;
|
||||
// CMake shuffles the include paths that it reports via the CodeBlocks generator
|
||||
// So remove the toolchain include paths, so that at least those end up in the correct
|
||||
// place.
|
||||
QStringList cxxflags = getCXXFlagsFor(cbt, targetDataCache);
|
||||
QSet<QString> tcIncludes;
|
||||
foreach (const HeaderPath &hp, tc->systemHeaderPaths(cxxflags, sysroot)) {
|
||||
tcIncludes.insert(hp.path());
|
||||
}
|
||||
QStringList includePaths;
|
||||
foreach (const QString &i, cbt.includeFiles) {
|
||||
if (!tcIncludes.contains(i))
|
||||
includePaths.append(i);
|
||||
}
|
||||
includePaths += projectDirectory().toString();
|
||||
ppBuilder.setIncludePaths(includePaths);
|
||||
QStringList cxxflags = getCXXFlagsFor(cbt, targetDataCache);
|
||||
ppBuilder.setCFlags(cxxflags);
|
||||
ppBuilder.setCxxFlags(cxxflags);
|
||||
ppBuilder.setDefines(cbt.defines);
|
||||
|
||||
Reference in New Issue
Block a user