summaryrefslogtreecommitdiffstats
path: root/cmake/QtInternalTargets.cmake
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-04-13 14:17:31 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-04-13 19:37:55 +0200
commitc91ae574edcd2dfb3a4364c34295886abf012704 (patch)
tree92a6551ef91774f97257344f82cd237d8c179035 /cmake/QtInternalTargets.cmake
parent4fb7eebc703434dad96e737a8850a44ab3975687 (diff)
Disable objc_msgSend stubs in static libs to maintain Xcode < 14 compat
Xcode 14's Clang will emit objc_msgSend stubs by default, which ld from earlier Xcode versions will fail to understand. Disable these stubs explicitly for static libs, for as long as we support Xcode < 14. See https://github.com/llvm/llvm-project/issues/56034 Pick-to: 6.5 Fixes: QTBUG-112820 Change-Id: Id762873d61b9d147bf3eb6292297e7b80b7393e1 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtInternalTargets.cmake')
-rw-r--r--cmake/QtInternalTargets.cmake15
1 files changed, 15 insertions, 0 deletions
diff --git a/cmake/QtInternalTargets.cmake b/cmake/QtInternalTargets.cmake
index 2208c28f34..b3c1f00345 100644
--- a/cmake/QtInternalTargets.cmake
+++ b/cmake/QtInternalTargets.cmake
@@ -217,6 +217,21 @@ elseif(UIKIT)
target_compile_definitions(PlatformCommonInternal INTERFACE GLES_SILENCE_DEPRECATION)
endif()
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang"
+ AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "14.0.0"
+)
+ # Xcode 14's Clang will emit objc_msgSend stubs by default, which ld
+ # from earlier Xcode versions will fail to understand when linking
+ # against static libraries with these stubs. Disable the stubs explicitly,
+ # for as long as we do support Xcode < 14.
+ set(is_static_lib "$<STREQUAL:$<TARGET_PROPERTY:TYPE>,STATIC_LIBRARY>")
+ set(is_objc "$<COMPILE_LANGUAGE:OBJC,OBJCXX>")
+ set(is_static_and_objc "$<AND:${is_static_lib},${is_objc}>")
+ target_compile_options(PlatformCommonInternal INTERFACE
+ "$<${is_static_and_objc}:-fno-objc-msgsend-selector-stubs>"
+ )
+endif()
+
if(MSVC)
target_compile_definitions(PlatformCommonInternal INTERFACE
"_CRT_SECURE_NO_WARNINGS"