summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-06-30 16:11:29 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-07-01 10:03:54 +0200
commita0468331761b497992e9d554c210583781308272 (patch)
treee7e060bbc22b01a70dacd0281163a8d2413b417c /cmake
parent36b0d9b51cd1c25d5e3decdd80d4b01420b11c17 (diff)
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>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuild.cmake10
-rw-r--r--cmake/QtInternalTargets.cmake16
2 files changed, 23 insertions, 3 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index ec4a156d54..f0adaf9379 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -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}
diff --git a/cmake/QtInternalTargets.cmake b/cmake/QtInternalTargets.cmake
index 9fca5d41de..6eb4bd96f9 100644
--- a/cmake/QtInternalTargets.cmake
+++ b/cmake/QtInternalTargets.cmake
@@ -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