aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2024-03-25 14:31:20 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2024-03-25 17:03:02 +0100
commitfce8fc22efe52b0d8b6f1f4633e8cc64e6641d2c (patch)
tree6d2e1d73e47048dc5ffc20ad101d45437d132ee6 /sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp
parent6785dc5fbfb99d08f32c6f28f3d5470cd7d5cec2 (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.7 6.6 6.5 6.2 Change-Id: Iacbdf1da3bc1f73757ff5231391ebe847158cc2d Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp')
-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 1f40f0a82..4c13b141f 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())