diff options
author | Marco Bubke <marco.bubke@qt.io> | 2018-08-14 13:07:04 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2018-08-14 15:03:51 +0000 |
commit | 7bae47642c3af7316ffe816bbf7a092b7f536c1e (patch) | |
tree | 5e1aad4cea4dec5837e3b6413a995a934d3a13e0 /src/plugins/cpptools/compileroptionsbuilder.cpp | |
parent | b592339b4d1741319b52144e23d255fa59ef0b63 (diff) | |
download | qt-creator-7bae47642c3af7316ffe816bbf7a092b7f536c1e.tar.gz |
Add optional system include to compiler option builder
System includes suppress warnings and prevent indexing of unwanted symbols.
Using system includes for all includes outside of the project can be
quite advantageous. The rootProjectDirectory() can be extended to be set
in the project settings. An automatic generation could be possible but
could create an unwanted path which includes files outside of the
perceived project.
Change-Id: Ib9d3158f14f41efe1f6657f962d5c4437bb324b2
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/plugins/cpptools/compileroptionsbuilder.cpp')
-rw-r--r-- | src/plugins/cpptools/compileroptionsbuilder.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/plugins/cpptools/compileroptionsbuilder.cpp b/src/plugins/cpptools/compileroptionsbuilder.cpp index 041cbf607b..aeb60a0f28 100644 --- a/src/plugins/cpptools/compileroptionsbuilder.cpp +++ b/src/plugins/cpptools/compileroptionsbuilder.cpp @@ -29,6 +29,7 @@ #include <coreplugin/vcsmanager.h> #include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/project.h> #include <utils/fileutils.h> #include <utils/qtcassert.h> @@ -38,8 +39,10 @@ namespace CppTools { -CompilerOptionsBuilder::CompilerOptionsBuilder(const ProjectPart &projectPart) - : m_projectPart(projectPart) +CompilerOptionsBuilder::CompilerOptionsBuilder(const ProjectPart &projectPart, + UseSystemHeader useSystemHeader) + : m_projectPart(projectPart), + m_useSystemHeader(useSystemHeader) { } @@ -188,7 +191,6 @@ void CompilerOptionsBuilder::enableExceptions() void CompilerOptionsBuilder::addHeaderPathOptions() { typedef ProjectPartHeaderPath HeaderPath; - const QString defaultPrefix = includeDirOption(); QStringList result; @@ -208,7 +210,7 @@ void CompilerOptionsBuilder::addHeaderPathOptions() default: // This shouldn't happen, but let's be nice..: // intentional fall-through: case HeaderPath::IncludePath: - prefix = defaultPrefix; + prefix = includeDirOptionForPath(headerPath.path); break; } @@ -423,9 +425,14 @@ void CompilerOptionsBuilder::addDefineFunctionMacrosMsvc() addMacros({{"__FUNCSIG__", "\"\""}, {"__FUNCTION__", "\"\""}, {"__FUNCDNAME__", "\"\""}}); } -QString CompilerOptionsBuilder::includeDirOption() const +QString CompilerOptionsBuilder::includeDirOptionForPath(const QString &path) const { - return QLatin1String("-I"); + if (m_useSystemHeader == UseSystemHeader::No + || path.startsWith(m_projectPart.project->rootProjectDirectory().toString())) { + return QString("-I"); + } else { + return QString("-isystem"); + } } QByteArray CompilerOptionsBuilder::macroOption(const ProjectExplorer::Macro ¯o) const |