aboutsummaryrefslogtreecommitdiffstats
path: root/src/app
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2019-07-22 15:51:50 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2019-08-14 11:44:51 +0000
commit18a3b64ab07ade6bfc9bb068956beed2032d9b58 (patch)
tree7bcb18c36f05508457074d783197cdd3f37f9fd6 /src/app
parent5320c8578b600081d9c5174f4024b726c5bdefa0 (diff)
C++: Add support for clang on Windows
This is about clang in "mingw mode", not clang-cl. When targeting Windows, clang is a lot like mingw, so factor out the common parts into a new base module. Testing uncovered a number of invalid assumptions in our autotests, which are also fixed in this patch. In addition, minor adjustments had to be made to the Qt.core module and to the qbscore lib. Change-Id: I73085dc62a65e2a9d0397cf234c8641989246f22 Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/app')
-rw-r--r--src/app/qbs-setup-toolchains/gccprobe.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/app/qbs-setup-toolchains/gccprobe.cpp b/src/app/qbs-setup-toolchains/gccprobe.cpp
index e979acf59..a8482f8d0 100644
--- a/src/app/qbs-setup-toolchains/gccprobe.cpp
+++ b/src/app/qbs-setup-toolchains/gccprobe.cpp
@@ -46,11 +46,14 @@
#include <tools/hostosinfo.h>
#include <tools/profile.h>
+#include <tools/settings.h>
#include <tools/toolchains.h>
#include <QtCore/qdir.h>
#include <QtCore/qprocess.h>
+#include <algorithm>
+
using namespace qbs;
using Internal::HostOsInfo;
using Internal::Tr;
@@ -395,6 +398,31 @@ Profile createGccProfile(const QFileInfo &compiler, Settings *settings,
setCommonProperties(profile, compiler, toolchainTypes, details);
+ if (HostOsInfo::isWindowsHost() && toolchainTypes.contains(QLatin1String("clang"))) {
+ const QStringList profileNames = settings->profiles();
+ bool foundMingw = false;
+ for (const QString &profileName : profileNames) {
+ const Profile otherProfile(profileName, settings);
+ if (otherProfile.value(QLatin1String("qbs.toolchainType")).toString()
+ == QLatin1String("mingw")
+ || otherProfile.value(QLatin1String("qbs.toolchain"))
+ .toStringList().contains(QLatin1String("mingw"))) {
+ const QFileInfo tcDir(otherProfile.value(QLatin1String("cpp.toolchainInstallPath"))
+ .toString());
+ if (!tcDir.fileName().isEmpty() && tcDir.exists()) {
+ profile.setValue(QLatin1String("qbs.sysroot"), tcDir.path());
+ foundMingw = true;
+ break;
+ }
+ }
+ }
+ if (!foundMingw) {
+ qbsWarning() << Tr::tr("Using clang on Windows requires a mingw installation. "
+ "Please set qbs.sysroot accordingly for profile '%1'.")
+ .arg(profile.name());
+ }
+ }
+
if (!toolchainTypes.contains(QLatin1String("clang"))) {
// Check whether auxiliary tools reside within the toolchain's install path.
// This might not be the case when using icecc or another compiler wrapper.
@@ -466,6 +494,16 @@ void gccProbe(Settings *settings, QList<Profile> &profiles, const QString &compi
return;
}
+ // Sort candidates so that mingw comes first. Information from mingw profiles is potentially
+ // used for setting up clang profiles.
+ if (HostOsInfo::isWindowsHost()) {
+ std::sort(candidates.begin(), candidates.end(),
+ [](const QFileInfo &fi1, const QFileInfo &fi2) {
+ return fi1.absoluteFilePath().contains(QLatin1String("mingw"))
+ && !fi2.absoluteFilePath().contains(QLatin1String("mingw"));
+ });
+ }
+
for (const auto &candidate : qAsConst(candidates)) {
const QStringList toolchainTypes = toolchainTypeFromCompilerName(
candidate.baseName());