Commit 4c62cbd6 authored by Benjamin Terrier's avatar Benjamin Terrier Committed by Orgad Shaneh

Add detection of MSVC 2017 Build Tools

Rename detectCppBuildTools() to detectCppBuildTools2015().
Add detectCppBuildTools2017(). Like the 2015 version the detection is
based on the presence of a .bat file because there are no entry in the
Windows registry, but it relies on the VisualStudioInstallation
structure like other Visual Studio toolchains.

Task-number: QTCREATORBUG-19053
Change-Id: I875bd466a3009574696fb7ebe54cdc5ff9bcb921
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: Friedemann Kleint's avatarFriedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Tobias Hunger's avatarTobias Hunger <tobias.hunger@qt.io>
parent dc8d0f04
......@@ -35,6 +35,7 @@
#include <utils/qtcassert.h>
#include <utils/hostosinfo.h>
#include <utils/temporarydirectory.h>
#include <utils/optional.h>
#include <QDir>
#include <QFileInfo>
......@@ -145,6 +146,33 @@ QDebug operator<<(QDebug d, const VisualStudioInstallation &i)
return d;
}
// Detect build tools introduced with MSVC2017
static Utils::optional<VisualStudioInstallation> detectCppBuildTools2017()
{
#ifdef Q_OS_WIN64
const char programFilesC[] = "ProgramFiles(x86)";
#else
const char programFilesC[] = "ProgramFiles";
#endif
const QString installPath = QDir::fromNativeSeparators(QFile::decodeName(qgetenv(programFilesC)))
+ "/Microsoft Visual Studio/2017/BuildTools";
const QString vcVarsPath = installPath + "/VC/Auxiliary/Build";
const QString vcVarsAllPath = vcVarsPath + "/vcvarsall.bat";
if (!QFileInfo::exists(vcVarsAllPath))
return Utils::nullopt;
VisualStudioInstallation installation;
installation.path = installPath;
installation.vcVarsAll = vcVarsAllPath;
installation.vcVarsPath = vcVarsPath;
installation.version = QVersionNumber(15);
installation.vsName = "15.0";
return installation;
}
static QVector<VisualStudioInstallation> detectVisualStudio()
{
QVector<VisualStudioInstallation> result;
......@@ -185,6 +213,12 @@ static QVector<VisualStudioInstallation> detectVisualStudio()
}
}
}
// Detect VS 2017 Build Tools
auto installation = detectCppBuildTools2017();
if (installation)
result.append(*installation);
return result;
}
......@@ -836,7 +870,7 @@ static QList<ToolChain *> findOrCreateToolChain(
}
// Detect build tools introduced with MSVC2015
static void detectCppBuildTools(QList<ToolChain *> *list)
static void detectCppBuildTools2015(QList<ToolChain *> *list)
{
struct Entry {
const char *postFix;
......@@ -989,7 +1023,7 @@ QList<ToolChain *> MsvcToolChainFactory::autoDetect(const QList<ToolChain *> &al
}
}
detectCppBuildTools(&results);
detectCppBuildTools2015(&results);
detectClangClToolChain(&results);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment