forked from qt-creator/qt-creator
CppTools: Do not use PCH when build PCH artifacts exist closeby
Clang cannot handle gcc pch files which are close to the forced include header. Fixes: QTCREATORBUG-22888 Change-Id: I0d678a889d1fb62bf3c6850277e13271efb91eea Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -172,6 +172,14 @@ void CompilerOptionsBuilder::addSyntaxOnly()
|
||||
isClStyle() ? add("/Zs") : add("-fsyntax-only");
|
||||
}
|
||||
|
||||
void CompilerOptionsBuilder::remove(const QStringList &args)
|
||||
{
|
||||
auto foundPos = std::search(m_options.begin(), m_options.end(),
|
||||
args.begin(), args.end());
|
||||
if (foundPos != m_options.end())
|
||||
m_options.erase(foundPos, std::next(foundPos, args.size()));
|
||||
}
|
||||
|
||||
QStringList createLanguageOptionGcc(ProjectFile::Kind fileKind, bool objcExt)
|
||||
{
|
||||
QStringList options;
|
||||
@@ -320,11 +328,18 @@ void CompilerOptionsBuilder::addHeaderPathOptions()
|
||||
|
||||
void CompilerOptionsBuilder::addPrecompiledHeaderOptions(UsePrecompiledHeaders usePrecompiledHeaders)
|
||||
{
|
||||
if (usePrecompiledHeaders == UsePrecompiledHeaders::No)
|
||||
return;
|
||||
|
||||
for (const QString &pchFile : m_projectPart.precompiledHeaders) {
|
||||
if (QFile::exists(pchFile)) {
|
||||
// Bail if build system precomiple header artifacts exists
|
||||
// Clang cannot handle foreign PCH files.
|
||||
if (QFile::exists(pchFile + ".gch") || QFile::exists(pchFile + ".pch"))
|
||||
usePrecompiledHeaders = UsePrecompiledHeaders::No;
|
||||
|
||||
if (usePrecompiledHeaders == UsePrecompiledHeaders::No) {
|
||||
// CMake PCH will already have force included the header file in
|
||||
// command line options, remove it if exists.
|
||||
remove({isClStyle() ? QLatin1String(includeFileOptionCl)
|
||||
: QLatin1String(includeFileOptionGcc), pchFile});
|
||||
} else if (QFile::exists(pchFile)) {
|
||||
add({isClStyle() ? QLatin1String(includeFileOptionCl)
|
||||
: QLatin1String(includeFileOptionGcc),
|
||||
QDir::toNativeSeparators(pchFile)});
|
||||
|
||||
@@ -85,6 +85,8 @@ public:
|
||||
void add(const QStringList &args, bool gccOnlyOptions = false);
|
||||
virtual void addExtraOptions() {}
|
||||
|
||||
void remove(const QStringList &args);
|
||||
|
||||
static UseToolchainMacros useToolChainMacros();
|
||||
void reset();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user