Commit 069bb2d3 authored by Tobias Hunger's avatar Tobias Hunger

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: default avatarTim Jenssen <>
parent c74a366d
......@@ -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);
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)) {
QStringList includePaths;
foreach (const QString &i, cbt.includeFiles) {
if (!tcIncludes.contains(i))
includePaths += projectDirectory().toString();
QStringList cxxflags = getCXXFlagsFor(cbt, targetDataCache);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment