From 1e1805ed36a932dcb085a1ad3308782a136d477c Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 8 Oct 2020 18:37:14 +0200 Subject: [PATCH] CMake: Workaround iOS Xcode issue when configuring app It appears that CMake's Xcode generator default behavior can't really handle imported object libraries location, which Qt uses extensively (all the qt_add_resource calls). Specifically the project fails to configure with the following error message: The OBJECT library type may not be used for IMPORTED libraries under Xcode with multiple architectures. An issue was filed upstream at https://gitlab.kitware.com/cmake/cmake/-/issues/21276 In the mean time, it looks like it's possible to work around the issue by setting XCODE_EMIT_EFFECTIVE_PLATFORM_NAME global property to OFF. This needs to be done before the very first project() call, so we do it in the generated Qt toolchain file. Note that the workaround only works if the CMake project is configured with a single architecture given to CMAKE_OSX_ARCHITECTURES. If multiple arches are given, it will fail with the same error message. Fixes: QTBUG-87198 Change-Id: I2556ae28b2fc2d9cfe464a5acf9c4fcbaf01b654 Reviewed-by: Joerg Bornemann --- cmake/QtBaseGlobalTargets.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake index b317d191b9..3558d6bbe5 100644 --- a/cmake/QtBaseGlobalTargets.cmake +++ b/cmake/QtBaseGlobalTargets.cmake @@ -208,6 +208,10 @@ endif()") list(APPEND init_platform "set(CMAKE_OSX_ARCHITECTURES \"${_qt_osx_architectures_escaped}\" CACHE STRING \"\")") unset(_qt_osx_architectures_escaped) + + list(APPEND init_platform "if(CMAKE_GENERATOR STREQUAL \"Xcode\" AND NOT QT_NO_XCODE_EMIT_EPN)") + list(APPEND init_platform " set_property(GLOBAL PROPERTY XCODE_EMIT_EFFECTIVE_PLATFORM_NAME OFF)") + list(APPEND init_platform "endif()") endif() elseif(ANDROID) list(APPEND init_platform "set(ANDROID_NATIVE_API_LEVEL \"${ANDROID_NATIVE_API_LEVEL}\" CACHE STRING \"\")")