CppTools: Add pre system include search path per project

Sometimes you want add a pre system include search path per project to
overload some system header for indexing. This can then even be checked in
the repository.

Change-Id: Ib103e5935d0553aa94522ed736f8c4eb2405a093
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2019-04-07 20:46:06 +02:00
parent 3bd653416a
commit 5ab057746c
9 changed files with 143 additions and 106 deletions

View File

@@ -29,6 +29,8 @@
#include <coreplugin/icore.h>
#endif
#include <projectexplorer/project.h>
#include <QRegularExpression>
namespace CppTools {
@@ -41,6 +43,8 @@ void HeaderPathFilter::process()
{
const HeaderPaths &headerPaths = projectPart.headerPaths;
addPreIncludesPath();
for (const HeaderPath &headerPath : headerPaths)
filterHeaderPath(headerPath);
@@ -141,6 +145,18 @@ void HeaderPathFilter::tweakHeaderPaths()
}
}
void HeaderPathFilter::addPreIncludesPath()
{
if (projectDirectory.size()) {
Utils::FileName rootProjectDirectory = Utils::FileName::fromString(projectDirectory);
rootProjectDirectory.appendPath(".pre_includes");
systemHeaderPaths.push_back(
{rootProjectDirectory.toString(), ProjectExplorer::HeaderPathType::System});
}
}
QString HeaderPathFilter::ensurePathWithSlashEnding(const QString &path)
{
QString pathWithSlashEnding = path;

View File

@@ -53,6 +53,8 @@ private:
void tweakHeaderPaths();
void addPreIncludesPath();
bool isProjectHeaderPath(const QString &path) const;
static QString ensurePathWithSlashEnding(const QString &path);