diff options
author | Cristian Adam <cristian.adam@qt.io> | 2019-11-01 13:29:35 +0100 |
---|---|---|
committer | Cristian Adam <cristian.adam@qt.io> | 2019-11-01 12:38:29 +0000 |
commit | a1d22fd2f79afab8b2379f6d93bcb417b9c8e7d5 (patch) | |
tree | d8afbf3d0c4b36a18aa2726d29452fce4a9a7128 | |
parent | 10d58b71309d438317da54b12f9df0ea83bbc1f5 (diff) | |
download | qt-creator-a1d22fd2f79afab8b2379f6d93bcb417b9c8e7d5.tar.gz |
CppTools: Fix code model for Clang builds
If you build Qt Creator with CMake version 3.16, you will have
precompile headers which will break code model.
Change-Id: I679936faed39ecfedb9ebb5fb553449a9f5ea29d
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
-rw-r--r-- | src/plugins/cpptools/compileroptionsbuilder.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/plugins/cpptools/compileroptionsbuilder.cpp b/src/plugins/cpptools/compileroptionsbuilder.cpp index aafcd35b37..ee534757ea 100644 --- a/src/plugins/cpptools/compileroptionsbuilder.cpp +++ b/src/plugins/cpptools/compileroptionsbuilder.cpp @@ -329,9 +329,14 @@ void CompilerOptionsBuilder::addPrecompiledHeaderOptions(UsePrecompiledHeaders u for (const QString &pchFile : m_projectPart.precompiledHeaders) { // Bail if build system precomiple header artifacts exists // Clang cannot handle foreign PCH files. - if (QFile::exists(pchFile + ".gch") || QFile::exists(pchFile + ".pch")) + if (QFile::exists(pchFile + ".gch") || QFile::exists(pchFile + ".pch")) { usePrecompiledHeaders = UsePrecompiledHeaders::No; + // In case of Clang compilers, remove the pch-inclusion arguments + remove({"-Xclang", "-include-pch", "-Xclang", pchFile + ".gch"}); + remove({"-Xclang", "-include-pch", "-Xclang", pchFile + ".pch"}); + } + if (usePrecompiledHeaders == UsePrecompiledHeaders::No) { // CMake PCH will already have force included the header file in // command line options, remove it if exists. |