From ccd2eb0e92a26b3c3a4aea12014a090269d5b7db Mon Sep 17 00:00:00 2001 From: Xavier BESSON Date: Mon, 30 Sep 2024 09:16:15 +0200 Subject: [PATCH] Add better naming for (recent) Microsoft Visual C++ compiler Fixes: QTCREATORBUG-31150 Change-Id: Id68107151898c95a621350d83a90539fca2cc1a8 Reviewed-by: Cristian Adam --- src/plugins/projectexplorer/msvctoolchain.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/plugins/projectexplorer/msvctoolchain.cpp b/src/plugins/projectexplorer/msvctoolchain.cpp index d7d87480136..cac80d12235 100644 --- a/src/plugins/projectexplorer/msvctoolchain.cpp +++ b/src/plugins/projectexplorer/msvctoolchain.cpp @@ -182,6 +182,7 @@ struct VisualStudioInstallation QString path; // Main installation path QString vcVarsPath; // Path under which the various vc..bat are to be found QString vcVarsAll; + QString displayName; }; QDebug operator<<(QDebug d, const VisualStudioInstallation &i) @@ -305,8 +306,12 @@ static QVector detectVisualStudioFromVsWhere(const QSt std::optional installation = installationFromPathAndVersion(installationPath, version); - if (installation) + if (installation) { + QJsonValue displayName = vsVersionObj.value("displayName"); + if (!displayName.isUndefined()) + installation->displayName = displayName.toString(); installations.append(*installation); + } } return installations; } @@ -449,7 +454,8 @@ static Abi findAbiOfMsvc(MsvcToolchain::Type type, static QString generateDisplayName(const QString &name, MsvcToolchain::Type t, - MsvcToolchain::Platform p) + MsvcToolchain::Platform p, + const QString &displayName = {}) { if (t == MsvcToolchain::WindowsSDK) { QString sdkName = name; @@ -458,6 +464,8 @@ static QString generateDisplayName(const QString &name, } // Comes as "9.0" from the registry QString vcName = QLatin1String("Microsoft Visual C++ Compiler "); + if (!displayName.isEmpty()) + vcName = QString::fromLatin1("%1 ").arg(displayName); vcName += name; vcName += QString::fromLatin1(" (%1)").arg(platformName(p)); return vcName; @@ -2019,7 +2027,7 @@ Toolchains MsvcToolchainFactory::autoDetect(const ToolchainDetector &detector) c if (hostSupportsPlatform(platform) && toolchainInstalled) { results.append( findOrCreateToolchains(detector, - generateDisplayName(i.vsName, MsvcToolchain::VS, platform), + generateDisplayName(i.vsName, MsvcToolchain::VS, platform, i.displayName), findAbiOfMsvc(MsvcToolchain::VS, platform, i.vsName), i.vcVarsAll, platformName(platform)));