Add support for Visual Studio 2017

Tested with RC

Task-number: QTBUG-57086
Change-Id: I21f56edca3852b52edd2c5fdcce76817141e8d4a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Oliver Wolff 2016-11-17 10:40:44 +01:00
parent 0a203faa7f
commit 38675e18fc
10 changed files with 83 additions and 6 deletions

View File

@ -0,0 +1,10 @@
#
# qmake configuration for win32-msvc2017
#
# Written for Microsoft Visual C++ 2017
#
MSC_VER = 1910
MSVC_VER = 15.0
include(../common/msvc-desktop.conf)
load(qt_config)

View File

@ -0,0 +1,34 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the qmake spec of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "../win32-msvc2005/qplatformdefs.h"

View File

@ -21,7 +21,7 @@ LINKER = link
CFLAGS_EXTRA = /Zc:wchar_t- CFLAGS_EXTRA = /Zc:wchar_t-
! elseif "$(QMAKESPEC)" == "win32-msvc2008" || "$(QMAKESPEC)" == "win32-msvc2010" || "$(QMAKESPEC)" == "win32-msvc2012" || "$(QMAKESPEC)" == "win32-msvc2013" ! elseif "$(QMAKESPEC)" == "win32-msvc2008" || "$(QMAKESPEC)" == "win32-msvc2010" || "$(QMAKESPEC)" == "win32-msvc2012" || "$(QMAKESPEC)" == "win32-msvc2013"
CFLAGS_EXTRA = /MP /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS $(CFLAGS_CRT) CFLAGS_EXTRA = /MP /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS $(CFLAGS_CRT)
! elseif "$(QMAKESPEC)" == "win32-msvc2015" ! elseif "$(QMAKESPEC)" == "win32-msvc2015" || "$(QMAKESPEC)" == "win32-msvc2017"
CFLAGS_EXTRA = /MP /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /Zc:strictStrings /w44456 /w44457 /w44458 /wd4577 $(CFLAGS_CRT) CFLAGS_EXTRA = /MP /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /Zc:strictStrings /w44456 /w44457 /w44458 /wd4577 $(CFLAGS_CRT)
! else ! else
! error Unsupported compiler for this Makefile ! error Unsupported compiler for this Makefile

View File

@ -57,7 +57,8 @@ enum DotNET {
NET2010 = 0xa0, NET2010 = 0xa0,
NET2012 = 0xb0, NET2012 = 0xb0,
NET2013 = 0xc0, NET2013 = 0xc0,
NET2015 = 0xd0 NET2015 = 0xd0,
NET2017 = 0xe0
}; };
/* /*

View File

@ -70,6 +70,7 @@ struct DotNetCombo {
const char *versionStr; const char *versionStr;
const char *regKey; const char *regKey;
} dotNetCombo[] = { } 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"}, {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 (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"}, {NET2013, "MSVC.NET 2013 Express Edition (12.0)", "Software\\Microsoft\\VCExpress\\12.0\\Setup\\VC\\ProductDir"},
@ -164,6 +165,8 @@ const char _slnHeader120[] = "Microsoft Visual Studio Solution File, Format
"\n# Visual Studio 2013"; "\n# Visual Studio 2013";
const char _slnHeader140[] = "Microsoft Visual Studio Solution File, Format Version 12.00" const char _slnHeader140[] = "Microsoft Visual Studio Solution File, Format Version 12.00"
"\n# Visual Studio 2015"; "\n# Visual Studio 2015";
const char _slnHeader141[] = "Microsoft Visual Studio Solution File, Format Version 12.00"
"\n# Visual Studio 2017";
// The following UUID _may_ change for later servicepacks... // The following UUID _may_ change for later servicepacks...
// If so we need to search through the registry at // If so we need to search through the registry at
// HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.0\Projects // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.0\Projects
@ -394,6 +397,8 @@ QString VcprojGenerator::retrievePlatformToolSet() const
return QStringLiteral("v120") + suffix; return QStringLiteral("v120") + suffix;
case NET2015: case NET2015:
return QStringLiteral("v140") + suffix; return QStringLiteral("v140") + suffix;
case NET2017:
return QStringLiteral("v141") + suffix;
default: default:
return QString(); return QString();
} }
@ -620,6 +625,9 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
} }
switch (which_dotnet_version(project->first("MSVC_VER").toLatin1())) { switch (which_dotnet_version(project->first("MSVC_VER").toLatin1())) {
case NET2017:
t << _slnHeader141;
break;
case NET2015: case NET2015:
t << _slnHeader140; t << _slnHeader140;
break; break;
@ -954,6 +962,9 @@ void VcprojGenerator::initProject()
// Own elements ----------------------------- // Own elements -----------------------------
vcProject.Name = project->first("QMAKE_ORIG_TARGET").toQString(); vcProject.Name = project->first("QMAKE_ORIG_TARGET").toQString();
switch (which_dotnet_version(project->first("MSVC_VER").toLatin1())) { switch (which_dotnet_version(project->first("MSVC_VER").toLatin1())) {
case NET2017:
vcProject.Version = "15.00";
break;
case NET2015: case NET2015:
vcProject.Version = "14.00"; vcProject.Version = "14.00";
break; break;

View File

@ -973,6 +973,13 @@ static ProString msvcBinDirToQMakeArch(QString subdir)
subdir = subdir.toLower(); subdir = subdir.toLower();
if (subdir == QLatin1String("amd64")) if (subdir == QLatin1String("amd64"))
return ProString("x86_64"); return ProString("x86_64");
// Since 2017 the folder structure from here is HostX64|X86/x64|x86
idx = subdir.indexOf(QLatin1Char('\\'));
if (idx == -1)
return ProString("x86");
subdir.remove(0, idx + 1);
if (subdir == QLatin1String("x64"))
return ProString("x86_64");
return ProString(subdir); return ProString(subdir);
} }
@ -1064,8 +1071,12 @@ void QMakeEvaluator::loadDefaults()
vars[ProKey("QMAKE_HOST.arch")] << archStr; vars[ProKey("QMAKE_HOST.arch")] << archStr;
# if defined(Q_CC_MSVC) // ### bogus condition, but nobody x-builds for msvc with a different qmake # if defined(Q_CC_MSVC) // ### bogus condition, but nobody x-builds for msvc with a different qmake
// Since VS 2017 we need VCToolsInstallDir instead of VCINSTALLDIR
QString vcInstallDir = m_option->getEnv(QLatin1String("VCToolsInstallDir"));
if (vcInstallDir.isEmpty())
vcInstallDir = m_option->getEnv(QLatin1String("VCINSTALLDIR"));
vars[ProKey("QMAKE_TARGET.arch")] = msvcArchitecture( vars[ProKey("QMAKE_TARGET.arch")] = msvcArchitecture(
m_option->getEnv(QLatin1String("VCINSTALLDIR")), vcInstallDir,
m_option->getEnv(QLatin1String("PATH"))); m_option->getEnv(QLatin1String("PATH")));
# endif # endif
#elif defined(Q_OS_UNIX) #elif defined(Q_OS_UNIX)

View File

@ -310,8 +310,10 @@ QLibraryInfo::buildDate()
# define COMPILER_STRING "MSVC 2012" # define COMPILER_STRING "MSVC 2012"
# elif _MSC_VER < 1900 # elif _MSC_VER < 1900
# define COMPILER_STRING "MSVC 2013" # define COMPILER_STRING "MSVC 2013"
# elif _MSC_VER < 2000 # elif _MSC_VER < 1910
# define COMPILER_STRING "MSVC 2015" # define COMPILER_STRING "MSVC 2015"
# elif _MSC_VER < 2000
# define COMPILER_STRING "MSVC 2017"
# else # else
# define COMPILER_STRING "MSVC _MSC_VER " QT_STRINGIFY(_MSC_VER) # define COMPILER_STRING "MSVC _MSC_VER " QT_STRINGIFY(_MSC_VER)
# endif # endif

View File

@ -1458,7 +1458,8 @@ void Configure::parseCmdLine()
dictionary[ "QMAKESPEC" ].endsWith("-msvc2010") || dictionary[ "QMAKESPEC" ].endsWith("-msvc2010") ||
dictionary[ "QMAKESPEC" ].endsWith("-msvc2012") || dictionary[ "QMAKESPEC" ].endsWith("-msvc2012") ||
dictionary[ "QMAKESPEC" ].endsWith("-msvc2013") || dictionary[ "QMAKESPEC" ].endsWith("-msvc2013") ||
dictionary[ "QMAKESPEC" ].endsWith("-msvc2015")) { dictionary[ "QMAKESPEC" ].endsWith("-msvc2015") ||
dictionary[ "QMAKESPEC" ].endsWith("-msvc2017")) {
if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "nmake"; if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "nmake";
dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32"; dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32";
} else if (dictionary[ "QMAKESPEC" ] == QString("win32-g++")) { } else if (dictionary[ "QMAKESPEC" ] == QString("win32-g++")) {

View File

@ -76,6 +76,7 @@ struct CompilerInfo{
{CC_MSVC2013, "Microsoft (R) Visual Studio 2013 C/C++ Compiler (12.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VC7\\12.0", "cl.exe"}, // link.exe, lib.exe {CC_MSVC2013, "Microsoft (R) Visual Studio 2013 C/C++ Compiler (12.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VC7\\12.0", "cl.exe"}, // link.exe, lib.exe
// Microsoft skipped version 13 // Microsoft skipped version 13
{CC_MSVC2015, "Microsoft (R) Visual Studio 2015 C/C++ Compiler (14.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VS7\\14.0", "cl.exe"}, // link.exe, lib.exe {CC_MSVC2015, "Microsoft (R) Visual Studio 2015 C/C++ Compiler (14.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VS7\\14.0", "cl.exe"}, // link.exe, lib.exe
{CC_MSVC2017, "Microsoft (R) Visual Studio 2017 C/C++ Compiler (15.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VS7\\15.0", "cl.exe"}, // link.exe, lib.exe
{CC_UNKNOWN, "Unknown", 0, 0}, {CC_UNKNOWN, "Unknown", 0, 0},
}; };
@ -101,6 +102,9 @@ QString Environment::detectQMakeSpec()
{ {
QString spec; QString spec;
switch (detectCompiler()) { switch (detectCompiler()) {
case CC_MSVC2017:
spec = "win32-msvc2017";
break;
case CC_MSVC2015: case CC_MSVC2015:
spec = "win32-msvc2015"; spec = "win32-msvc2015";
break; break;
@ -137,6 +141,8 @@ QString Environment::detectQMakeSpec()
Compiler Environment::compilerFromQMakeSpec(const QString &qmakeSpec) Compiler Environment::compilerFromQMakeSpec(const QString &qmakeSpec)
{ {
if (qmakeSpec == QLatin1String("win32-msvc2017"))
return CC_MSVC2017;
if (qmakeSpec == QLatin1String("win32-msvc2015")) if (qmakeSpec == QLatin1String("win32-msvc2015"))
return CC_MSVC2015; return CC_MSVC2015;
if (qmakeSpec == QLatin1String("win32-msvc2013")) if (qmakeSpec == QLatin1String("win32-msvc2013"))

View File

@ -46,7 +46,8 @@ enum Compiler {
CC_MSVC2010 = 0xA0, CC_MSVC2010 = 0xA0,
CC_MSVC2012 = 0xB0, CC_MSVC2012 = 0xB0,
CC_MSVC2013 = 0xC0, CC_MSVC2013 = 0xC0,
CC_MSVC2015 = 0xD0 CC_MSVC2015 = 0xD0,
CC_MSVC2017 = 0xE0
}; };
struct CompilerInfo; struct CompilerInfo;