summaryrefslogtreecommitdiffstats
path: root/qmake/generators/win32
diff options
context:
space:
mode:
Diffstat (limited to 'qmake/generators/win32')
-rw-r--r--qmake/generators/win32/msbuild_objectmodel.cpp23
-rw-r--r--qmake/generators/win32/msvc_objectmodel.cpp95
-rw-r--r--qmake/generators/win32/msvc_objectmodel.h2
-rw-r--r--qmake/generators/win32/msvc_vcproj.cpp29
-rw-r--r--qmake/generators/win32/msvc_vcproj.h5
-rw-r--r--qmake/generators/win32/winmakefile.cpp4
6 files changed, 77 insertions, 81 deletions
diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp
index ad2976aa01..0e95766f8e 100644
--- a/qmake/generators/win32/msbuild_objectmodel.cpp
+++ b/qmake/generators/win32/msbuild_objectmodel.cpp
@@ -34,7 +34,6 @@
#include <qscopedpointer.h>
#include <qstringlist.h>
#include <qfileinfo.h>
-#include <qversionnumber.h>
QT_BEGIN_NAMESPACE
@@ -625,31 +624,17 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool)
<< tagValue("RootNamespace", tool.Name)
<< tagValue("Keyword", tool.Keyword);
- QString windowsTargetPlatformVersion;
if (isWinRT) {
xml << tagValue("MinimumVisualStudioVersion", tool.Version)
<< tagValue("DefaultLanguage", "en")
<< tagValue("AppContainerApplication", "true")
<< tagValue("ApplicationType", "Windows Store")
<< tagValue("ApplicationTypeRevision", tool.SdkVersion);
- if (tool.SdkVersion == "10.0")
- windowsTargetPlatformVersion = qgetenv("UCRTVERSION");
- } else {
- QByteArray winSDKVersionStr = qgetenv("WindowsSDKVersion").trimmed();
-
- // This environment variable might end with a backslash due to a VS bug.
- if (winSDKVersionStr.endsWith('\\'))
- winSDKVersionStr.chop(1);
-
- QVersionNumber winSDKVersion = QVersionNumber::fromString(
- QString::fromLocal8Bit(winSDKVersionStr));
- if (!winSDKVersion.isNull())
- windowsTargetPlatformVersion = winSDKVersionStr;
- }
- if (!windowsTargetPlatformVersion.isEmpty()) {
- xml << tagValue("WindowsTargetPlatformVersion", windowsTargetPlatformVersion)
- << tagValue("WindowsTargetPlatformMinVersion", windowsTargetPlatformVersion);
}
+ if (!tool.WindowsTargetPlatformVersion.isEmpty())
+ xml << tagValue("WindowsTargetPlatformVersion", tool.WindowsTargetPlatformVersion);
+ if (!tool.WindowsTargetPlatformMinVersion.isEmpty())
+ xml << tagValue("WindowsTargetPlatformMinVersion", tool.WindowsTargetPlatformMinVersion);
xml << closetag();
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
diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h
index 9d1a170489..f8f9804c27 100644
--- a/qmake/generators/win32/msvc_objectmodel.h
+++ b/qmake/generators/win32/msvc_objectmodel.h
@@ -1123,6 +1123,8 @@ public:
QString SccLocalPath;
QString PlatformName;
QString SdkVersion;
+ QString WindowsTargetPlatformVersion;
+ QString WindowsTargetPlatformMinVersion;
// Single projects
QList<VCProjectSingleConfig> SingleProjects;
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
index 95c16661e7..d231260886 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -191,6 +191,10 @@ bool VcprojGenerator::writeProjectMakefile()
mergedProject.SccProjectName = mergedProjects.at(0)->vcProject.SccProjectName;
mergedProject.SccLocalPath = mergedProjects.at(0)->vcProject.SccLocalPath;
mergedProject.PlatformName = mergedProjects.at(0)->vcProject.PlatformName;
+ mergedProject.WindowsTargetPlatformVersion =
+ project->first("WINDOWS_TARGET_PLATFORM_VERSION").toQString();
+ mergedProject.WindowsTargetPlatformMinVersion =
+ project->first("WINDOWS_TARGET_PLATFORM_MIN_VERSION").toQString();
XmlOutput xmlOut(t);
projectWriter->write(xmlOut, mergedProject);
@@ -473,8 +477,8 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash<QSt
// Add all unknown libs to the deps
QStringList where = QStringList() << "LIBS" << "LIBS_PRIVATE"
<< "QMAKE_LIBS" << "QMAKE_LIBS_PRIVATE";
- for (QStringList::ConstIterator wit = where.begin();
- wit != where.end(); ++wit) {
+ for (QStringList::ConstIterator wit = where.cbegin();
+ wit != where.cend(); ++wit) {
const ProStringList &l = tmp_proj.values(ProKey(*wit));
for (ProStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
const QString opt = fixLibFlag(*it).toQString();
@@ -771,8 +775,9 @@ void VcprojGenerator::init()
// Setup PCH variables
precompH = project->first("PRECOMPILED_HEADER").toQString();
- precompCPP = project->first("PRECOMPILED_SOURCE").toQString();
- usePCH = !precompH.isEmpty() && project->isActiveConfig("precompile_header");
+ precompSource = project->first("PRECOMPILED_SOURCE").toQString();
+ pchIsCFile = project->isActiveConfig("precompile_header_c");
+ usePCH = !precompH.isEmpty() && (pchIsCFile || project->isActiveConfig("precompile_header"));
if (usePCH) {
precompHFilename = fileInfo(precompH).fileName();
// Created files
@@ -786,13 +791,15 @@ void VcprojGenerator::init()
project->values("PRECOMPILED_OBJECT") = ProStringList(precompObj);
project->values("PRECOMPILED_PCH") = ProStringList(precompPch);
- autogenPrecompCPP = precompCPP.isEmpty() && project->isActiveConfig("autogen_precompile_source");
- if (autogenPrecompCPP) {
- precompCPP = precompH
- + (Option::cpp_ext.count() ? Option::cpp_ext.at(0) : QLatin1String(".cpp"));
- project->values("GENERATED_SOURCES") += precompCPP;
- } else if (!precompCPP.isEmpty()) {
- project->values("SOURCES") += precompCPP;
+ autogenPrecompSource = precompSource.isEmpty() && project->isActiveConfig("autogen_precompile_source");
+ if (autogenPrecompSource) {
+ precompSource = precompH
+ + (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;
+ } else if (!precompSource.isEmpty()) {
+ project->values("SOURCES") += precompSource;
}
}
diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h
index 6af5ec7007..6f9743cb09 100644
--- a/qmake/generators/win32/msvc_vcproj.h
+++ b/qmake/generators/win32/msvc_vcproj.h
@@ -57,15 +57,16 @@ public:
~VcprojGenerator();
QString defaultMakefile() const;
- QString precompH, precompHFilename, precompCPP,
+ QString precompH, precompHFilename, precompSource,
precompObj, precompPch;
- bool autogenPrecompCPP;
+ bool autogenPrecompSource;
static bool hasBuiltinCompiler(const QString &file);
QHash<QString, QStringList> extraCompilerSources;
QHash<QString, QString> extraCompilerOutputs;
const QString customBuildToolFilterFileSuffix;
bool usePCH;
+ bool pchIsCFile = false;
VCProjectWriter *projectWriter;
protected:
diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp
index 91215c94b1..6e4b9a1eb5 100644
--- a/qmake/generators/win32/winmakefile.cpp
+++ b/qmake/generators/win32/winmakefile.cpp
@@ -112,8 +112,8 @@ Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
goto found;
}
QString libBase = (*dir_it).local() + '/' + lib + verovr;
- for (ProStringList::ConstIterator extit = impexts.begin();
- extit != impexts.end(); ++extit) {
+ for (ProStringList::ConstIterator extit = impexts.cbegin();
+ extit != impexts.cend(); ++extit) {
if (exists(libBase + '.' + *extit)) {
(*it) = cand + verovr + '.' + *extit;
goto found;