diff options
author | Ivan Komissarov <abbapoh@gmail.com> | 2019-12-08 01:53:16 +0300 |
---|---|---|
committer | Ivan Komissarov <ABBAPOH@gmail.com> | 2019-12-10 12:29:19 +0000 |
commit | a499ac2a80967da83cd39d66d64f88c6b3d57205 (patch) | |
tree | 3d27fc213f75fa754d97c38500f5b0c9294fd6e6 | |
parent | fa73a6da5a0b48738198ec9762b6950bcb398800 (diff) |
Fix auto-detection of the clang-cl installed with Visual Studiov1.15.0
It is possible (since VS 2017) to install LLVM tools using Visual Studio
installer. These are not registered in Windows registry, but can be
detected manually
Change-Id: I80b29f14c73c331f1812ee6c995e83b3207e0816
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r-- | src/app/qbs-setup-toolchains/clangclprobe.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/app/qbs-setup-toolchains/clangclprobe.cpp b/src/app/qbs-setup-toolchains/clangclprobe.cpp index 816d28546..820d06b43 100644 --- a/src/app/qbs-setup-toolchains/clangclprobe.cpp +++ b/src/app/qbs-setup-toolchains/clangclprobe.cpp @@ -107,9 +107,9 @@ std::vector<MSVCInstallInfo> compatibleMsvcs() return msvcs; } -QString findCompatibleVcsarsallBat() +QString findCompatibleVcsarsallBat(const std::vector<MSVCInstallInfo> &msvcs) { - for (const auto &msvc: compatibleMsvcs()) { + for (const auto &msvc: msvcs) { const auto vcvarsallPath = msvc.findVcvarsallBat(); if (!vcvarsallPath.isEmpty()) return vcvarsallPath; @@ -126,8 +126,12 @@ QString wow6432Key() #endif } -QString findClangCl() +// Function can modify passed list in case it has found clang in one of the VS installation - +// in that case, there's no point in looking for vcvarsall.bat among all installed VSs, we just +// use .bat file corresponding to that particular VS installation +QString findClangCl(std::vector<MSVCInstallInfo> *msvcs) { + Q_ASSERT(msvcs); const auto compilerName = HostOsInfo::appendExecutableSuffix(QStringLiteral("clang-cl")); const auto compilerFromPath = findExecutable(compilerName); if (!compilerFromPath.isEmpty()) @@ -154,6 +158,17 @@ QString findClangCl() if (QFileInfo(compilerPath).exists()) return compilerPath; } + + // If we didn't find custom LLVM installation, try to find if it's installed with Visual Studio + for (const auto &msvc : *msvcs) { + const auto compilerPath = QStringLiteral("%1/VC/Tools/Llvm/bin/%2") + .arg(msvc.installDir, compilerName); + if (QFileInfo(compilerPath).exists()) { + *msvcs = {msvc}; // reduce list to one installation + return compilerPath; + } + } + return {}; } @@ -163,7 +178,7 @@ void createClangClProfile(const QFileInfo &compiler, Settings *settings, const QString &profileName) { const auto compilerName = QStringLiteral("clang-cl"); - const auto vcvarsallPath = findCompatibleVcsarsallBat(); + const auto vcvarsallPath = findCompatibleVcsarsallBat(compatibleMsvcs()); if (vcvarsallPath.isEmpty()) { qbsWarning() << Tr::tr("%1 requires installed Visual Studio 2017 or newer, but none was found.") @@ -182,15 +197,17 @@ void createClangClProfile(const QFileInfo &compiler, Settings *settings, */ void clangClProbe(Settings *settings, QList<Profile> &profiles) { + auto msvcs = compatibleMsvcs(); + const auto compilerName = QStringLiteral("clang-cl"); qbsInfo() << Tr::tr("Trying to detect %1...").arg(compilerName); - const QString compilerFilePath = findClangCl(); + const QString compilerFilePath = findClangCl(&msvcs); if (compilerFilePath.isEmpty()) { qbsInfo() << Tr::tr("%1 was not found.").arg(compilerName); return; } const QFileInfo compiler(compilerFilePath); - const auto vcvarsallPath = findCompatibleVcsarsallBat(); + const auto vcvarsallPath = findCompatibleVcsarsallBat(msvcs); if (vcvarsallPath.isEmpty()) { qbsWarning() << Tr::tr("%1 requires installed Visual Studio 2017 or newer, but none was found.") |