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>
This commit is contained in:
Cristian Adam
2019-11-01 13:29:35 +01:00
parent 10d58b7130
commit a1d22fd2f7

View File

@@ -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.