CMake: Apply bitcode flags to internal plugin object lib initializers

All internal libraries, plugins, object libraries (resources, plugin
initializers) need to be built with bitcode flags when targeting iOS.

Internal here means all libraries added by qt_internal_add_X
functions or associated with internal libraries.

We didn't do that for plugin initializers, which were added not too
long ago.

Extract the logic that links to Qt::PlatformModuleInternal into a
separate function to be used for object libraries.
Use it for resources and plugin initializers. It will also be used
in qtdeclarative for qml plugin initializers.

Pick-to: 6.2
Task-number: QTBUG-95208
Change-Id: I366996078f5e9d1c2d2797f6b81c522ee99529e3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2021-07-15 13:41:15 +02:00
parent 3595613a0a
commit e0a0101290
3 changed files with 12 additions and 4 deletions

View File

@ -329,6 +329,7 @@ function(qt_internal_add_plugin target)
if(qt_module_target) if(qt_module_target)
__qt_internal_add_static_plugin_init_object_library("${target}" plugin_init_target) __qt_internal_add_static_plugin_init_object_library("${target}" plugin_init_target)
qt_internal_link_internal_platform_for_object_library("${plugin_init_target}")
endif() endif()
endif() endif()

View File

@ -87,10 +87,7 @@ function(qt_internal_record_rcc_object_files target resource_targets)
endif() endif()
set_property(TARGET ${target} APPEND PROPERTY _qt_rcc_objects "${rcc_object_file_path}") 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 qt_internal_link_internal_platform_for_object_library("${out_target}")
# flags, needed for building iOS apps with qmake where bitcode is involved.
target_link_libraries("${out_target}" PRIVATE Qt::PlatformModuleInternal)
qt_set_common_target_properties(${out_target}) qt_set_common_target_properties(${out_target})
endforeach() endforeach()
endfunction() endfunction()

View File

@ -762,3 +762,13 @@ endfunction()
function(qt_internal_mark_as_internal_library target) function(qt_internal_mark_as_internal_library target)
set_target_properties(${target} PROPERTIES _qt_is_internal_library TRUE) set_target_properties(${target} PROPERTIES _qt_is_internal_library TRUE)
endfunction() endfunction()
function(qt_internal_link_internal_platform_for_object_library target)
# We need to apply iOS bitcode flags to object libraries that are associated with internal
# modules or plugins (e.g. object libraries added by qt_internal_add_resource,
# qt_internal_add_plugin, etc.)
# The flags are needed when building iOS apps because Xcode expects bitcode to be
# present by default.
# Achieve this by compiling the cpp files with the PlatformModuleInternal compile flags.
target_link_libraries("${target}" PRIVATE Qt::PlatformModuleInternal)
endfunction()