summaryrefslogtreecommitdiffstats
path: root/qmake/generators/win32/msvc_objectmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qmake/generators/win32/msvc_objectmodel.cpp')
-rw-r--r--qmake/generators/win32/msvc_objectmodel.cpp95
1 files changed, 48 insertions, 47 deletions
diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp
index 4f0cee65e1..7caa94c512 100644
--- a/qmake/generators/win32/msvc_objectmodel.cpp
+++ b/qmake/generators/win32/msvc_objectmodel.cpp
@@ -2213,8 +2213,49 @@ void VCFilter::addFiles(const ProStringList& fileList)
void VCFilter::modifyPCHstage(QString str)
{
- bool autogenSourceFile = Project->autogenPrecompCPP;
- bool pchThroughSourceFile = !Project->precompCPP.isEmpty();
+ const bool isHFile = (str == Project->precompH);
+ const bool pchThroughSourceFile = !Project->precompSource.isEmpty();
+ if (isHFile && pchThroughSourceFile && Project->autogenPrecompSource) {
+ useCustomBuildTool = true;
+ QString toFile(Project->precompSource);
+ CustomBuildTool.Description = "Generating precompiled header source file '" + toFile + "' ...";
+ CustomBuildTool.Outputs += toFile;
+
+ QStringList lines;
+ CustomBuildTool.CommandLine +=
+ "echo /*-------------------------------------------------------------------- >" + toFile;
+ lines << "* Precompiled header source file used by Visual Studio.NET to generate";
+ lines << "* the .pch file.";
+ lines << "*";
+ lines << "* Due to issues with the dependencies checker within the IDE, it";
+ lines << "* sometimes fails to recompile the PCH file, if we force the IDE to";
+ lines << "* create the PCH file directly from the header file.";
+ lines << "*";
+ lines << "* This file is auto-generated by qmake since no PRECOMPILED_SOURCE was";
+ lines << "* specified, and is used as the common stdafx.cpp. The file is only";
+ lines << QLatin1String("* generated when creating ")
+ + (Config->CompilerVersion < NET2010 ? ".vcproj" : ".vcxproj")
+ + " project files, and is not used for";
+ lines << "* command line compilations by nmake.";
+ lines << "*";
+ lines << "* WARNING: All changes made in this file will be lost.";
+ lines << "--------------------------------------------------------------------*/";
+ lines << "#include \"" + Project->precompHFilename + "\"";
+ for (const QString &line : qAsConst(lines))
+ CustomBuildTool.CommandLine += "echo " + line + ">>" + toFile;
+ return;
+ }
+
+ useCompilerTool = true;
+ const bool isPrecompSource = pchThroughSourceFile && (str == Project->precompSource);
+ if (isPrecompSource) {
+ CompilerTool.UsePrecompiledHeader = pchCreateUsingSpecific;
+ if (Project->autogenPrecompSource)
+ CompilerTool.PrecompiledHeaderThrough = Project->precompHFilename;
+ 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)) {
@@ -2222,53 +2263,13 @@ void VCFilter::modifyPCHstage(QString str)
break;
}
}
- const bool isHFile = (str == Project->precompH);
- bool isCPPFile = pchThroughSourceFile && (str == Project->precompCPP);
-
- if(!isCFile && !isHFile && !isCPPFile)
- return;
-
- if(isHFile && pchThroughSourceFile) {
- if (autogenSourceFile) {
- useCustomBuildTool = true;
- QString toFile(Project->precompCPP);
- CustomBuildTool.Description = "Generating precompiled header source file '" + toFile + "' ...";
- CustomBuildTool.Outputs += toFile;
-
- QStringList lines;
- CustomBuildTool.CommandLine +=
- "echo /*-------------------------------------------------------------------- >" + toFile;
- lines << "* Precompiled header source file used by Visual Studio.NET to generate";
- lines << "* the .pch file.";
- lines << "*";
- lines << "* Due to issues with the dependencies checker within the IDE, it";
- lines << "* sometimes fails to recompile the PCH file, if we force the IDE to";
- lines << "* create the PCH file directly from the header file.";
- lines << "*";
- lines << "* This file is auto-generated by qmake since no PRECOMPILED_SOURCE was";
- lines << "* specified, and is used as the common stdafx.cpp. The file is only";
- lines << QLatin1String("* generated when creating ")
- + (Config->CompilerVersion < NET2010 ? ".vcproj" : ".vcxproj")
- + " project files, and is not used for";
- lines << "* command line compilations by nmake.";
- lines << "*";
- lines << "* WARNING: All changes made in this file will be lost.";
- lines << "--------------------------------------------------------------------*/";
- lines << "#include \"" + Project->precompHFilename + "\"";
- for (const QString &line : qAsConst(lines))
- CustomBuildTool.CommandLine += "echo " + line + ">>" + toFile;
- }
- return;
- }
- useCompilerTool = true;
- // Setup PCH options
- CompilerTool.UsePrecompiledHeader = (isCFile ? pchNone : pchCreateUsingSpecific);
- if (isCFile)
+ bool pchCompatible = (isCFile == Project->pchIsCFile);
+ if (!pchCompatible) {
+ CompilerTool.UsePrecompiledHeader = pchNone;
CompilerTool.PrecompiledHeaderThrough = QLatin1String("$(NOINHERIT)");
- else if (autogenSourceFile)
- CompilerTool.PrecompiledHeaderThrough = Project->precompHFilename;
- CompilerTool.ForcedIncludeFiles = QStringList("$(NOINHERIT)");
+ CompilerTool.ForcedIncludeFiles = QStringList("$(NOINHERIT)");
+ }
}
VCFilterFile VCFilter::findFile(const QString &filePath, bool *found) const