CMake: Use -fapplication-extension when building Qt libraries on macOS

Needed to avoid linker warnings transformed into errors, when linking
QtWebEngine with qmake mixing.

ld: warning: linking against a dylib which is not safe for use in
application extensions:

The flag is added to libraries and plugins, unless opted out.

CMake equivalent of 944110089d

Task-number: QTBUG-83929
Task-number: QTBUG-75666
Change-Id: I3e9acca4712c9a266bf54c6e35e2fd2c0096692b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
bb10
Alexandru Croitor 2020-05-27 14:42:35 +02:00
parent f20f0b03d5
commit e189126f1a
4 changed files with 31 additions and 0 deletions

View File

@ -204,3 +204,22 @@ function(qt_auto_detect_fpmath)
endif()
endfunction()
qt_auto_detect_fpmath()
function(qt_handle_apple_app_extension_api_only)
if(APPLE)
# Build Qt libraries with -fapplication-extension. Needed to avoid linker warnings
# transformed into errors on darwin platforms.
set(flags "-fapplication-extension")
set(genex_condition "$<NOT:$<BOOL:$<TARGET_PROPERTY:QT_NO_APP_EXTENSION_ONLY_API>>>")
set(flags "$<${genex_condition}:${flags}>")
target_compile_options(PlatformModuleInternal INTERFACE ${flags})
target_link_options(PlatformModuleInternal INTERFACE ${flags})
target_compile_options(PlatformPluginInternal INTERFACE ${flags})
target_link_options(PlatformPluginInternal INTERFACE ${flags})
endif()
endfunction()
function(qt_disable_apple_app_extension_api_only target)
set_target_properties("${target}" PROPERTIES QT_NO_APP_EXTENSION_ONLY_API TRUE)
endfunction()
qt_handle_apple_app_extension_api_only()

View File

@ -63,6 +63,10 @@ qt_internal_add_plugin(QCocoaIntegrationPlugin
Qt::ThemeSupportPrivate
)
# special case begin
qt_disable_apple_app_extension_api_only(QCocoaIntegrationPlugin)
# special case end
# Resources:
set(qcocoaresources_resource_files
"images/sizeallcursor.png"

View File

@ -37,6 +37,10 @@ add_qt_plugin(QIOSIntegrationPlugin
Qt::GuiPrivate
)
# special case begin
qt_disable_apple_app_extension_api_only(QIOSIntegrationPlugin)
# special case end
#### Keys ignored in scope 1:.:.:kernel.pro:<TRUE>:
# OTHER_FILES = "quiview_textinput.mm" "quiview_accessibility.mm"

View File

@ -64,6 +64,10 @@ qt_add_module(XcbQpa
XKB::XKB
)
# special case begin
qt_disable_apple_app_extension_api_only(XcbQpa)
# special case end
## Scopes:
#####################################################################