summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoahelpers.mm
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-11-30 14:51:18 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-12-03 22:44:45 +0000
commitb82559244e2dc03f1ceff66bb67630df4300dc7c (patch)
treebc952f388c9074439c62659176215eb6595c3c6e /src/plugins/platforms/cocoa/qcocoahelpers.mm
parent1314d2688c6eab24d33e2a558403fa6e2482f849 (diff)
macOS: Account for LC_BUILD_VERSION when checking SDK version and deployment target
The more modern LC_BUILD_VERSION load command was introduced in the 10.13 SDK to unify the various versions of the LC_*_VERSION_MIN command. When building with a deployment target of 10.14, the linker will use this load command instead. Change-Id: Ic3571fdbfdf4dfb9346128c6f6e75d1e06f86cd2 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoahelpers.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm
index 36841c77ab..d86e935788 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.mm
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm
@@ -402,23 +402,30 @@ QOperatingSystemVersion QMacVersion::currentRuntime()
QMacVersion::VersionTuple QMacVersion::versionsForImage(const mach_header *machHeader)
{
+ static auto makeVersionTuple = [](uint32_t dt, uint32_t sdk) {
+ return qMakePair(
+ QOperatingSystemVersion(QOperatingSystemVersion::MacOS,
+ dt >> 16 & 0xffff, dt >> 8 & 0xff, dt & 0xff),
+ QOperatingSystemVersion(QOperatingSystemVersion::MacOS,
+ sdk >> 16 & 0xffff, sdk >> 8 & 0xff, sdk & 0xff)
+ );
+ };
+
auto commandCursor = uintptr_t(machHeader) + sizeof(mach_header_64);
for (uint32_t i = 0; i < machHeader->ncmds; ++i) {
load_command *loadCommand = reinterpret_cast<load_command *>(commandCursor);
if (loadCommand->cmd == LC_VERSION_MIN_MACOSX) {
auto versionCommand = reinterpret_cast<version_min_command *>(loadCommand);
- uint32_t dt = versionCommand->version; // Deployment target
- uint32_t sdk = versionCommand->sdk; // Build SDK
- return qMakePair(
- QOperatingSystemVersion(QOperatingSystemVersion::MacOS,
- dt >> 16 & 0xffff, dt >> 8 & 0xff, dt & 0xff),
- QOperatingSystemVersion(QOperatingSystemVersion::MacOS,
- sdk >> 16 & 0xffff, sdk >> 8 & 0xff, sdk & 0xff)
- );
+ return makeVersionTuple(versionCommand->version, versionCommand->sdk);
+#if QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13)
+ } else if (loadCommand->cmd == LC_BUILD_VERSION) {
+ auto versionCommand = reinterpret_cast<build_version_command *>(loadCommand);
+ return makeVersionTuple(versionCommand->minos, versionCommand->sdk);
+#endif
}
commandCursor += loadCommand->cmdsize;
}
- Q_ASSERT_X(false, "QCocoaIntegration", "Could not find version-min load command");
+ Q_ASSERT_X(false, "QCocoaIntegration", "Could not find any version load command");
Q_UNREACHABLE();
}