summaryrefslogtreecommitdiffstats
path: root/cmake/QtInternalTargets.cmake
diff options
context:
space:
mode:
authorAmir Masoud Abdol <amir.abdol@qt.io>2023-10-16 11:24:38 +0200
committerAmir Masoud Abdol <amir.abdol@qt.io>2023-10-24 22:10:43 +0200
commit66b7cb2a88a0cb1251f1d7c39231ab1e8a35b470 (patch)
tree9ab6adb3a8f19a606bdb9735d31239cd8119b655 /cmake/QtInternalTargets.cmake
parent2d59f2e8caed71d4eceb1abe3ce17b7befb40559 (diff)
Suppress "duplicate libraries" warning for Xcode 15
A bug in Xcode 15 adds duplicate flags to the linker. In addition, the `-warn_duplicate_libraries` is now enabled by default which may result in several 'duplicate libraries warning', and build failure if `-Wl,-fatal_warnings` is passed. By adding the newly introduced flag, `-no_warn_duplicate_libraries`, to the linker we can suppress the warnings, and possible fatal error caused by this bug. Change-Id: I65e06ea039a6e98b02ed1f9112c622ecc6a142b5 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'cmake/QtInternalTargets.cmake')
-rw-r--r--cmake/QtInternalTargets.cmake35
1 files changed, 22 insertions, 13 deletions
diff --git a/cmake/QtInternalTargets.cmake b/cmake/QtInternalTargets.cmake
index 52ba63c762..29e3483c71 100644
--- a/cmake/QtInternalTargets.cmake
+++ b/cmake/QtInternalTargets.cmake
@@ -229,19 +229,28 @@ 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>"
- )
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
+ if(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(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "15.0.0")
+ # A bug in Xcode 15 adds duplicate flags to the linker. In addition, the
+ # `-warn_duplicate_libraries` is now enabled by default which may result
+ # in several 'duplicate libraries warning'.
+ # - https://gitlab.kitware.com/cmake/cmake/-/issues/25297 and
+ # - https://indiestack.com/2023/10/xcode-15-duplicate-library-linker-warnings/
+ target_link_options(PlatformCommonInternal INTERFACE
+ "LINKER:-no_warn_duplicate_libraries")
+ endif()
endif()
if(MSVC)