aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2024-03-25 14:31:20 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-03-25 20:57:03 +0000
commiteff0cdf2cdda70135a7c0d5e00fe10f2c399b304 (patch)
tree7fca639dd43f508de00707dd3a7bda5fcfd932d1
parente3f09ad2c021a0160103ae7548f8018e13e5a994 (diff)
Fix build with MSVC
Add /Zc:__cplusplus, fixing: QtCore/qcompilerdetection.h(1257): fatal error C1189: #error: "Qt requires a C++17 compiler, and a suitable value for __cplusplus. On MSVC, you must pass the /Zc:__cplusplus option to the compiler." Also update the emulated MSVC version for libclang 18. Pick-to: 6.5 6.2 Change-Id: Iacbdf1da3bc1f73757ff5231391ebe847158cc2d Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> (cherry picked from commit fce8fc22efe52b0d8b6f1f4633e8cc64e6641d2c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 114d900b011123cbc9cbd79b720105201bae8aa5)
-rw-r--r--sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp
index b3cce9e86..e8250f900 100644
--- a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp
+++ b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp
@@ -94,6 +94,12 @@ bool setPlatform(const QString &name)
return result;
}
+// 3/2024: Use a recent MSVC2022 for libclang 18.X
+static QByteArray msvcCompatVersion()
+{
+ return libClangVersion() >= QVersionNumber(0, 64) ? "19.39"_ba : "19.26"_ba;
+}
+
static bool runProcess(const QString &program, const QStringList &arguments,
QByteArray *stdOutIn = nullptr, QByteArray *stdErrIn = nullptr)
{
@@ -365,9 +371,10 @@ QByteArrayList emulatedCompilerOptions()
HeaderPaths headerPaths;
switch (compiler()) {
case Compiler::Msvc:
- result.append(QByteArrayLiteral("-fms-compatibility-version=19.26.28806"));
+ result.append("-fms-compatibility-version="_ba + msvcCompatVersion());
result.append(QByteArrayLiteral("-fdelayed-template-parsing"));
result.append(QByteArrayLiteral("-Wno-microsoft-enum-value"));
+ result.append("/Zc:__cplusplus"_ba);
// Fix yvals_core.h: STL1000: Unexpected compiler version, expected Clang 7 or newer (MSVC2017 update)
result.append(QByteArrayLiteral("-D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH"));
if (needsClangBuiltinIncludes())