Support 'CONFIG += precompile_header_c' in VS projects
The CONFIG value precompile_header_c was ignored in the VS project generator. Add a member VcprojGenerator::pchIsCFile that is set to true if precompile_header_c is active. The code in modifyPCHstage had to be rearranged to separate the three parts for stable.h, stable.cpp and other files. Task-number: QTBUG-62821 Change-Id: I340eb165baa22cafcb64815cf223ce9a21aca558 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
parent
e5f94f0f05
commit
e04aaf188c
@ -2213,20 +2213,8 @@ void VCFilter::addFiles(const ProStringList& fileList)
|
|||||||
|
|
||||||
void VCFilter::modifyPCHstage(QString str)
|
void VCFilter::modifyPCHstage(QString str)
|
||||||
{
|
{
|
||||||
bool pchThroughSourceFile = !Project->precompSource.isEmpty();
|
|
||||||
bool isCFile = false;
|
|
||||||
for (QStringList::Iterator it = Option::c_ext.begin(); it != Option::c_ext.end(); ++it) {
|
|
||||||
if (str.endsWith(*it)) {
|
|
||||||
isCFile = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const bool isHFile = (str == Project->precompH);
|
const bool isHFile = (str == Project->precompH);
|
||||||
bool isCPPFile = pchThroughSourceFile && (str == Project->precompSource);
|
const bool pchThroughSourceFile = !Project->precompSource.isEmpty();
|
||||||
|
|
||||||
if(!isCFile && !isHFile && !isCPPFile)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (isHFile && pchThroughSourceFile && Project->autogenPrecompSource) {
|
if (isHFile && pchThroughSourceFile && Project->autogenPrecompSource) {
|
||||||
useCustomBuildTool = true;
|
useCustomBuildTool = true;
|
||||||
QString toFile(Project->precompSource);
|
QString toFile(Project->precompSource);
|
||||||
@ -2259,13 +2247,29 @@ void VCFilter::modifyPCHstage(QString str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
useCompilerTool = true;
|
useCompilerTool = true;
|
||||||
// Setup PCH options
|
const bool isPrecompSource = pchThroughSourceFile && (str == Project->precompSource);
|
||||||
CompilerTool.UsePrecompiledHeader = (isCFile ? pchNone : pchCreateUsingSpecific);
|
if (isPrecompSource) {
|
||||||
if (isCFile)
|
CompilerTool.UsePrecompiledHeader = pchCreateUsingSpecific;
|
||||||
CompilerTool.PrecompiledHeaderThrough = QLatin1String("$(NOINHERIT)");
|
if (Project->autogenPrecompSource)
|
||||||
else if (Project->autogenPrecompSource)
|
|
||||||
CompilerTool.PrecompiledHeaderThrough = Project->precompHFilename;
|
CompilerTool.PrecompiledHeaderThrough = Project->precompHFilename;
|
||||||
CompilerTool.ForcedIncludeFiles = QStringList("$(NOINHERIT)");
|
CompilerTool.ForcedIncludeFiles = QStringList("$(NOINHERIT)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isCFile = false;
|
||||||
|
for (QStringList::Iterator it = Option::c_ext.begin(); it != Option::c_ext.end(); ++it) {
|
||||||
|
if (str.endsWith(*it)) {
|
||||||
|
isCFile = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pchCompatible = (isCFile == Project->pchIsCFile);
|
||||||
|
if (!pchCompatible) {
|
||||||
|
CompilerTool.UsePrecompiledHeader = pchNone;
|
||||||
|
CompilerTool.PrecompiledHeaderThrough = QLatin1String("$(NOINHERIT)");
|
||||||
|
CompilerTool.ForcedIncludeFiles = QStringList("$(NOINHERIT)");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VCFilterFile VCFilter::findFile(const QString &filePath, bool *found) const
|
VCFilterFile VCFilter::findFile(const QString &filePath, bool *found) const
|
||||||
|
@ -776,7 +776,8 @@ void VcprojGenerator::init()
|
|||||||
// Setup PCH variables
|
// Setup PCH variables
|
||||||
precompH = project->first("PRECOMPILED_HEADER").toQString();
|
precompH = project->first("PRECOMPILED_HEADER").toQString();
|
||||||
precompSource = project->first("PRECOMPILED_SOURCE").toQString();
|
precompSource = project->first("PRECOMPILED_SOURCE").toQString();
|
||||||
usePCH = !precompH.isEmpty() && project->isActiveConfig("precompile_header");
|
pchIsCFile = project->isActiveConfig("precompile_header_c");
|
||||||
|
usePCH = !precompH.isEmpty() && (pchIsCFile || project->isActiveConfig("precompile_header"));
|
||||||
if (usePCH) {
|
if (usePCH) {
|
||||||
precompHFilename = fileInfo(precompH).fileName();
|
precompHFilename = fileInfo(precompH).fileName();
|
||||||
// Created files
|
// Created files
|
||||||
@ -793,7 +794,9 @@ void VcprojGenerator::init()
|
|||||||
autogenPrecompSource = precompSource.isEmpty() && project->isActiveConfig("autogen_precompile_source");
|
autogenPrecompSource = precompSource.isEmpty() && project->isActiveConfig("autogen_precompile_source");
|
||||||
if (autogenPrecompSource) {
|
if (autogenPrecompSource) {
|
||||||
precompSource = precompH
|
precompSource = precompH
|
||||||
+ (Option::cpp_ext.count() ? Option::cpp_ext.at(0) : QLatin1String(".cpp"));
|
+ (pchIsCFile
|
||||||
|
? (Option::c_ext.count() ? Option::c_ext.at(0) : QLatin1String(".c"))
|
||||||
|
: (Option::cpp_ext.count() ? Option::cpp_ext.at(0) : QLatin1String(".cpp")));
|
||||||
project->values("GENERATED_SOURCES") += precompSource;
|
project->values("GENERATED_SOURCES") += precompSource;
|
||||||
} else if (!precompSource.isEmpty()) {
|
} else if (!precompSource.isEmpty()) {
|
||||||
project->values("SOURCES") += precompSource;
|
project->values("SOURCES") += precompSource;
|
||||||
|
@ -66,6 +66,7 @@ public:
|
|||||||
QHash<QString, QString> extraCompilerOutputs;
|
QHash<QString, QString> extraCompilerOutputs;
|
||||||
const QString customBuildToolFilterFileSuffix;
|
const QString customBuildToolFilterFileSuffix;
|
||||||
bool usePCH;
|
bool usePCH;
|
||||||
|
bool pchIsCFile = false;
|
||||||
VCProjectWriter *projectWriter;
|
VCProjectWriter *projectWriter;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user