CMake: Enable bitcode when targeting UIKIT aka iOS
Building an iOS app with qmake failed because Qt itself was not built with bitcode enabled. Enable building with bitcode. Make sure qrc resource files and bundled 3rd party libraries also build with the regular Qt module flags and thus with bitcode enabled. As a consequence gc_sections has to be disabled for UIKIT platforms. Task-number: QTBUG-82581 Task-number: QTBUG-84781 Task-number: QTBUG-85240 Change-Id: I15fe668725a139c02f2a32a5db849b46d4ce325c Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
36b0d9b51c
commit
a046833176
@ -1667,7 +1667,7 @@ function(qt_internal_apply_gc_binaries target visibility)
|
||||
message(FATAL_ERROR "Visibitily setting must be one of PRIVATE, INTERFACE or PUBLIC.")
|
||||
endif()
|
||||
|
||||
if ((GCC OR CLANG) AND NOT EMSCRIPTEN)
|
||||
if ((GCC OR CLANG) AND NOT EMSCRIPTEN AND NOT UIKIT)
|
||||
if(APPLE)
|
||||
set(gc_sections_flag "-Wl,-dead_strip")
|
||||
elseif(SOLARIS)
|
||||
@ -1680,7 +1680,7 @@ function(qt_internal_apply_gc_binaries target visibility)
|
||||
target_link_options("${target}" ${visibility} "${gc_sections_flag}")
|
||||
endif()
|
||||
|
||||
if((GCC OR CLANG OR ICC) AND NOT EMSCRIPTEN)
|
||||
if((GCC OR CLANG OR ICC) AND NOT EMSCRIPTEN AND NOT UIKIT)
|
||||
set(split_sections_flags "-ffunction-sections" "-fdata-sections")
|
||||
endif()
|
||||
if(split_sections_flags)
|
||||
@ -3835,6 +3835,10 @@ function(qt_add_resource target resourceName)
|
||||
set(rcc_object_file_path $<TARGET_OBJECTS:$<TARGET_NAME:${out_target}>>)
|
||||
endif()
|
||||
set_property(TARGET ${target} APPEND PROPERTY QT_RCC_OBJECTS "${rcc_object_file_path}")
|
||||
|
||||
# Make sure that the target cpp files are compiled with the regular Qt internal compile
|
||||
# flags, needed for building iOS apps with qmake where bitcode is involved.
|
||||
target_link_libraries("${out_target}" PRIVATE Qt::PlatformModuleInternal)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
@ -4520,7 +4524,7 @@ function(qt_add_3rdparty_library target)
|
||||
DEFINES
|
||||
${arg_DEFINES}
|
||||
PUBLIC_LIBRARIES ${arg_PUBLIC_LIBRARIES}
|
||||
LIBRARIES ${arg_LIBRARIES}
|
||||
LIBRARIES ${arg_LIBRARIES} Qt::PlatformModuleInternal
|
||||
COMPILE_OPTIONS ${arg_COMPILE_OPTIONS}
|
||||
PUBLIC_COMPILE_OPTIONS ${arg_PUBLIC_COMPILE_OPTIONS}
|
||||
LINK_OPTIONS ${arg_LINK_OPTIONS}
|
||||
|
@ -108,6 +108,21 @@ endif()
|
||||
|
||||
target_compile_definitions(PlatformCommonInternal INTERFACE $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>)
|
||||
|
||||
function(qt_internal_apply_bitcode_flags target)
|
||||
# See mkspecs/features/uikit/bitcode.prf
|
||||
set(release_flags "-fembed-bitcode")
|
||||
set(debug_flags "-fembed-bitcode-marker")
|
||||
|
||||
set(is_release_genex "$<NOT:$<CONFIG:Debug>>")
|
||||
set(flags_genex "$<IF:${is_release_genex},${release_flags},${debug_flags}>")
|
||||
set(is_enabled_genex "$<NOT:$<BOOL:$<TARGET_PROPERTY:QT_NO_BITCODE>>>")
|
||||
|
||||
set(bitcode_flags "$<${is_enabled_genex}:${flags_genex}>")
|
||||
|
||||
target_link_options("${target}" INTERFACE ${bitcode_flags})
|
||||
target_compile_options("${target}" INTERFACE ${bitcode_flags})
|
||||
endfunction()
|
||||
|
||||
if(UIKIT)
|
||||
# Do what mkspecs/features/uikit/default_pre.prf does, aka enable sse2 for
|
||||
# simulator_and_device_builds.
|
||||
@ -118,6 +133,7 @@ if(UIKIT)
|
||||
# TODO: Figure out if this ok or not (sounds ok to me).
|
||||
target_compile_definitions(PlatformCommonInternal INTERFACE QT_COMPILER_SUPPORTS_SSE2)
|
||||
endif()
|
||||
qt_internal_apply_bitcode_flags(PlatformCommonInternal)
|
||||
endif()
|
||||
|
||||
# Taken from mkspecs/common/msvc-version.conf and mkspecs/common/msvc-desktop.conf
|
||||
|
Loading…
x
Reference in New Issue
Block a user