summaryrefslogtreecommitdiffstats
path: root/qmake/generators/win32/msvc_vcproj.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qmake/generators/win32/msvc_vcproj.cpp')
-rw-r--r--qmake/generators/win32/msvc_vcproj.cpp132
1 files changed, 13 insertions, 119 deletions
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
index a7312d0124..48b8bea812 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -35,7 +35,6 @@
#include <qdir.h>
#include <qdiriterator.h>
#include <qcryptographichash.h>
-#include <qregexp.h>
#include <qhash.h>
#include <quuid.h>
@@ -57,98 +56,6 @@ const char _GUIDFormFiles[] = "{99349809-55BA-4b9d-BF79-8FDBB0286EB3}
const char _GUIDExtraCompilerFiles[] = "{E0D8C965-CC5F-43d7-AD63-FAEF0BBC0F85}";
const char _GUIDDeploymentFiles[] = "{D9D6E243-F8AF-46E4-B9FD-80ECBC20BA3E}";
const char _GUIDDistributionFiles[] = "{B83CAF91-C7BF-462F-B76C-EA11631F866C}";
-QT_END_NAMESPACE
-
-#ifdef Q_OS_WIN32
-#include <qt_windows.h>
-#include <registry_p.h>
-
-QT_BEGIN_NAMESPACE
-
-struct DotNetCombo {
- DotNET version;
- const char *versionStr;
- const char *regKey;
-} dotNetCombo[] = {
- {NET2017, "MSVC.NET 2017 (15.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VS7\\15.0"},
- {NET2015, "MSVC.NET 2015 (14.0)", "Software\\Microsoft\\VisualStudio\\14.0\\Setup\\VC\\ProductDir"},
- {NET2013, "MSVC.NET 2013 (12.0)", "Software\\Microsoft\\VisualStudio\\12.0\\Setup\\VC\\ProductDir"},
- {NET2013, "MSVC.NET 2013 Express Edition (12.0)", "Software\\Microsoft\\VCExpress\\12.0\\Setup\\VC\\ProductDir"},
- {NET2012, "MSVC.NET 2012 (11.0)", "Software\\Microsoft\\VisualStudio\\11.0\\Setup\\VC\\ProductDir"},
- {NET2012, "MSVC.NET 2012 Express Edition (11.0)", "Software\\Microsoft\\VCExpress\\11.0\\Setup\\VC\\ProductDir"},
- {NET2010, "MSVC.NET 2010 (10.0)", "Software\\Microsoft\\VisualStudio\\10.0\\Setup\\VC\\ProductDir"},
- {NET2010, "MSVC.NET 2010 Express Edition (10.0)", "Software\\Microsoft\\VCExpress\\10.0\\Setup\\VC\\ProductDir"},
- {NET2008, "MSVC.NET 2008 (9.0)", "Software\\Microsoft\\VisualStudio\\9.0\\Setup\\VC\\ProductDir"},
- {NET2008, "MSVC.NET 2008 Express Edition (9.0)", "Software\\Microsoft\\VCExpress\\9.0\\Setup\\VC\\ProductDir"},
- {NET2005, "MSVC.NET 2005 (8.0)", "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir"},
- {NET2005, "MSVC.NET 2005 Express Edition (8.0)", "Software\\Microsoft\\VCExpress\\8.0\\Setup\\VC\\ProductDir"},
- {NET2003, "MSVC.NET 2003 (7.1)", "Software\\Microsoft\\VisualStudio\\7.1\\Setup\\VC\\ProductDir"},
- {NET2002, "MSVC.NET 2002 (7.0)", "Software\\Microsoft\\VisualStudio\\7.0\\Setup\\VC\\ProductDir"},
- {NETUnknown, "", ""},
-};
-
-QT_END_NAMESPACE
-#endif
-
-QT_BEGIN_NAMESPACE
-DotNET which_dotnet_version(const QByteArray &preferredVersion = QByteArray())
-{
-#ifndef Q_OS_WIN32
- Q_UNUSED(preferredVersion);
- return NET2002; // Always generate 7.0 versions on other platforms
-#else
- // Only search for the version once
- static DotNET current_version = NETUnknown;
- if(current_version != NETUnknown)
- return current_version;
-
- // Fallback to .NET 2002
- current_version = NET2002;
-
- const DotNetCombo *lowestInstalledVersion = 0;
- QHash<DotNET, QString> installPaths;
- int installed = 0;
- int i = 0;
- for(; dotNetCombo[i].version; ++i) {
- QString path = qt_readRegistryKey(HKEY_LOCAL_MACHINE, dotNetCombo[i].regKey,
- KEY_WOW64_32KEY);
- if (!path.isEmpty() && installPaths.value(dotNetCombo[i].version) != path) {
- lowestInstalledVersion = &dotNetCombo[i];
- installPaths.insert(lowestInstalledVersion->version, path);
- ++installed;
- current_version = lowestInstalledVersion->version;
- if (QByteArray(lowestInstalledVersion->versionStr).contains(preferredVersion)) {
- installed = 1;
- break;
- }
- }
- }
-
- if (installed < 2)
- return current_version;
-
- // More than one version installed, search directory path
- QString paths = qgetenv("PATH");
- const QStringList pathlist = paths.split(QLatin1Char(';'));
- for (const QString &path : pathlist) {
- for (i = 0; dotNetCombo[i].version; ++i) {
- const QString productPath = installPaths.value(dotNetCombo[i].version);
- if (productPath.isEmpty())
- continue;
- if (path.startsWith(productPath, Qt::CaseInsensitive)) {
- current_version = dotNetCombo[i].version;
- return current_version;
- }
- }
- }
-
- warn_msg(WarnLogic, "Generator: MSVC.NET: Found more than one version of Visual Studio, but"
- " none in your PATH. Falling back to lowest version (%s)",
- qPrintable(lowestInstalledVersion->versionStr));
-
- return current_version;
-#endif
-};
// Flatfile Tags ----------------------------------------------------
const char _slnHeader70[] = "Microsoft Visual Studio Solution File, Format Version 7.00";
@@ -384,20 +291,16 @@ QString VcprojGenerator::retrievePlatformToolSet() const
if (!envVar.isEmpty())
return envVar;
- QString suffix;
- if (project->isActiveConfig("winphone"))
- suffix = '_' + project->first("WINTARGET_VER").toQString().toLower();
-
switch (vcProject.Configuration.CompilerVersion)
{
case NET2012:
- return QStringLiteral("v110") + suffix;
+ return QStringLiteral("v110");
case NET2013:
- return QStringLiteral("v120") + suffix;
+ return QStringLiteral("v120");
case NET2015:
- return QStringLiteral("v140") + suffix;
+ return QStringLiteral("v140");
case NET2017:
- return QStringLiteral("v141") + suffix;
+ return QStringLiteral("v141");
default:
return QString();
}
@@ -624,7 +527,7 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
return;
}
- switch (which_dotnet_version(project->first("MSVC_VER").toLatin1())) {
+ switch (vcProject.Configuration.CompilerVersion) {
case NET2017:
t << _slnHeader141;
break;
@@ -654,7 +557,8 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
break;
default:
t << _slnHeader70;
- warn_msg(WarnLogic, "Generator: MSVC.NET: Unknown version (%d) of MSVC detected for .sln", which_dotnet_version());
+ warn_msg(WarnLogic, "Generator: MSVC.NET: Unknown version (%d) of MSVC detected for .sln",
+ vcProject.Configuration.CompilerVersion);
break;
}
@@ -969,7 +873,7 @@ void VcprojGenerator::initProject()
// Own elements -----------------------------
vcProject.Name = project->first("QMAKE_ORIG_TARGET").toQString();
- switch (which_dotnet_version(project->first("MSVC_VER").toLatin1())) {
+ switch (vcProject.Configuration.CompilerVersion) {
case NET2017:
vcProject.Version = "15.00";
break;
@@ -1001,7 +905,7 @@ void VcprojGenerator::initProject()
break;
default:
vcProject.Version = "7.00";
- warn_msg(WarnLogic, "Generator: MSVC.NET: Unknown version (%d) of MSVC detected for .vcproj", which_dotnet_version());
+ warn_msg(WarnLogic, "Generator: MSVC.NET: Unknown version (%d) of MSVC detected for .vcproj", vcProject.Configuration.CompilerVersion);
break;
}
@@ -1025,12 +929,11 @@ void VcprojGenerator::initConfiguration()
// - to know of certain compiler/linker options
VCConfiguration &conf = vcProject.Configuration;
conf.suppressUnknownOptionWarnings = project->isActiveConfig("suppress_vcproj_warnings");
- conf.CompilerVersion = which_dotnet_version(project->first("MSVC_VER").toLatin1());
+ conf.CompilerVersion = vsVersionFromString(project->first("MSVC_VER"));
if (conf.CompilerVersion >= NET2012) {
conf.WinRT = project->isActiveConfig("winrt");
if (conf.WinRT) {
- conf.WinPhone = project->isActiveConfig("winphone");
// Saner defaults
conf.compiler.UsePrecompiledHeader = pchNone;
conf.compiler.CompileAsWinRT = _False;
@@ -1431,18 +1334,9 @@ void VcprojGenerator::initWinDeployQtTool()
// structure (for instance for plugins). However, the MDILXapCompile call
// itself contains the original subdirectories as parameters and hence the
// call fails.
- // Neither there is a way to disable this behavior for Windows Phone, nor
- // to influence the parameters. Hence the only way to get a build
- // done is to recreate the directory structure manually by invoking
- // windeployqt a second time, so that the MDILXapCompile call succeeds and
- // deployment continues.
- if (conf.WinPhone) {
- conf.windeployqt.CommandLine = commandLine
- + QStringLiteral(" -list relative -dir \"$(MSBuildProjectDirectory)\\")
- + var("OBJECTS_DIR")
- + QStringLiteral("MSIL\" \"$(OutDir)\\$(TargetName).exe\" ")
- + QLatin1String(" && ");
- }
+ // Hence the only way to get a build done is to recreate the directory
+ // structure manually by invoking windeployqt a second time, so that
+ // the MDILXapCompile call succeeds and deployment continues.
conf.windeployqt.CommandLine += commandLine
+ QStringLiteral(" -list relative -dir \"$(MSBuildProjectDirectory)\" \"$(OutDir)\\$(TargetName).exe\" > ")
+ MakefileGenerator::shellQuote(conf.windeployqt.Record);