diff options
-rw-r--r-- | src/app/qbs-setup-toolchains/msvcprobe.cpp | 6 | ||||
-rw-r--r-- | src/lib/corelib/tools/msvcinfo.cpp | 11 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/app/qbs-setup-toolchains/msvcprobe.cpp b/src/app/qbs-setup-toolchains/msvcprobe.cpp index bb54add9f..19da1e25a 100644 --- a/src/app/qbs-setup-toolchains/msvcprobe.cpp +++ b/src/app/qbs-setup-toolchains/msvcprobe.cpp @@ -58,6 +58,7 @@ #include <QtCore/qstringlist.h> #include <algorithm> +#include <unordered_set> #include <vector> using namespace qbs; @@ -182,9 +183,14 @@ void msvcProbe(Settings *settings, std::vector<Profile> &profiles) } } + std::unordered_set<QString> seenNames; for (MSVC &msvc : msvcs) { const QString name = QLatin1String("MSVC") + msvc.version + QLatin1Char('-') + msvc.architecture; + // TODO: Qbs currently does not support multiple versions of installed MSVCs + // so we stop at the first (the newest) one + if (!seenNames.insert(name).second) + continue; try { msvc.init(); addMSVCPlatform(settings, profiles, name, &msvc); diff --git a/src/lib/corelib/tools/msvcinfo.cpp b/src/lib/corelib/tools/msvcinfo.cpp index 42cfefe7b..83c53ba5c 100644 --- a/src/lib/corelib/tools/msvcinfo.cpp +++ b/src/lib/corelib/tools/msvcinfo.cpp @@ -43,6 +43,7 @@ #include <logging/logger.h> #include <tools/error.h> #include <tools/profile.h> +#include <tools/stlutils.h> #include <tools/stringconstants.h> #include <QtCore/qbytearray.h> @@ -471,12 +472,20 @@ static std::vector<MSVC> installedCompilersHelper(Logger &logger) QDir vcInstallDir = vsInstallDir; vcInstallDir.cd(QStringLiteral("Tools/MSVC")); const auto vcVersionStrs = vcInstallDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); + std::vector<Version> vcVersions; + vcVersions.reserve(vcVersionStrs.size()); for (const QString &vcVersionStr : vcVersionStrs) { const Version vcVersion = Version::fromString(vcVersionStr); if (!vcVersion.isValid()) continue; + vcVersions.push_back(vcVersion); + } + // sort the versions so the new one comes first + std::sort(vcVersions.begin(), vcVersions.end(), std::greater()); + + for (const Version &vcVersion : vcVersions) { QDir specificVcInstallDir = vcInstallDir; - if (!specificVcInstallDir.cd(vcVersionStr) + if (!specificVcInstallDir.cd(vcVersion.toString()) || !specificVcInstallDir.cd(QStringLiteral("bin"))) { continue; } |