diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2018-09-20 23:38:06 +0300 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2018-09-25 12:44:00 +0000 |
commit | f07396b86f281d7b2d9dd938fbaca44fe610c113 (patch) | |
tree | d18489ac5563e945189fc8c4838b752d3cefa296 /src/plugins/cpptools/compileroptionsbuilder.cpp | |
parent | cc1e03a64936e5c35a941b327418d114accdaf23 (diff) | |
download | qt-creator-f07396b86f281d7b2d9dd938fbaca44fe610c113.tar.gz |
CppTools: Apply SkipBuiltIn also to toolchain defines
The only place where Yes is used is the compilation DB, which doesn't
need these defines anyway.
Also add -fPIC for Qt compatibility.
This reduces the compile_commands.json file for Qt Creator from 180M to 33M.
Change-Id: Idd3b363c3a143b1d79f97962c4ff9ee61d7767a4
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/plugins/cpptools/compileroptionsbuilder.cpp')
-rw-r--r-- | src/plugins/cpptools/compileroptionsbuilder.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/plugins/cpptools/compileroptionsbuilder.cpp b/src/plugins/cpptools/compileroptionsbuilder.cpp index 812de0fb59..8ec63484f9 100644 --- a/src/plugins/cpptools/compileroptionsbuilder.cpp +++ b/src/plugins/cpptools/compileroptionsbuilder.cpp @@ -43,14 +43,14 @@ namespace CppTools { CompilerOptionsBuilder::CompilerOptionsBuilder(const ProjectPart &projectPart, UseSystemHeader useSystemHeader, - SkipBuiltIn skipBuiltInHeaderPaths, + SkipBuiltIn skipBuiltInHeaderPathsAndDefines, QString clangVersion, QString clangResourceDirectory) : m_projectPart(projectPart) , m_useSystemHeader(useSystemHeader) , m_clangVersion(clangVersion) , m_clangResourceDirectory(clangResourceDirectory) - , m_skipBuiltInHeaderPaths(skipBuiltInHeaderPaths) + , m_skipBuiltInHeaderPathsAndDefines(skipBuiltInHeaderPathsAndDefines) { } @@ -85,7 +85,7 @@ QStringList CompilerOptionsBuilder::build(CppTools::ProjectFile::Kind fileKind, undefineCppLanguageFeatureMacrosForMsvc2015(); addDefineFunctionMacrosMsvc(); - addGlobalUndef(); + addToolchainFlags(); addPrecompiledHeaderOptions(pchUsage); addHeaderPathOptions(); addProjectConfigFileInclude(); @@ -305,7 +305,7 @@ void CompilerOptionsBuilder::addHeaderPathOptions() m_options.append(includes); m_options.append(systemIncludes); - if (m_skipBuiltInHeaderPaths == SkipBuiltIn::Yes) + if (m_skipBuiltInHeaderPathsAndDefines == SkipBuiltIn::Yes) return; // Exclude all built-in includes except Clang resource directory. @@ -351,7 +351,8 @@ void CompilerOptionsBuilder::addPrecompiledHeaderOptions(PchUsage pchUsage) void CompilerOptionsBuilder::addToolchainAndProjectMacros() { - addMacros(m_projectPart.toolChainMacros); + if (m_skipBuiltInHeaderPathsAndDefines == SkipBuiltIn::No) + addMacros(m_projectPart.toolChainMacros); addMacros(m_projectPart.projectMacros); } @@ -634,12 +635,15 @@ void CompilerOptionsBuilder::addWrappedQtHeadersIncludePath(QStringList &list) } } -void CompilerOptionsBuilder::addGlobalUndef() +void CompilerOptionsBuilder::addToolchainFlags() { // In case of MSVC we need builtin clang defines to correctly handle clang includes if (m_projectPart.toolchainType != ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID - && m_projectPart.toolchainType != ProjectExplorer::Constants::CLANG_CL_TOOLCHAIN_TYPEID) { - add("-undef"); + && m_projectPart.toolchainType != ProjectExplorer::Constants::CLANG_CL_TOOLCHAIN_TYPEID) { + if (m_skipBuiltInHeaderPathsAndDefines == SkipBuiltIn::No) + add("-undef"); + else + add("-fPIC"); } } |