diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-08-05 16:49:42 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-08-10 16:51:53 +0200 |
commit | 5161d8d525650ac74a3571b13bb8b35dbf413e59 (patch) | |
tree | 762ffeaf4ef6a0ee750677aafe8412824c466451 /src/corelib/Qt6CoreMacros.cmake | |
parent | f95a446641ac84c7756d184a7ee996fc538a18c9 (diff) |
CMake: Remove qt6_enable_object_libraries_finalizer_mode
qt6_enable_object_libraries_finalizer_mode is not needed anymore
now that static Qt builds require CMake 3.21 and thus CMake takes
care of placing object library object files at the beginning of
the link line.
Rename qt6_enable_import_plugins_finalizer_mode to a more generic
qt6_set_finalizer_mode that can enable or disable multiple
different modes.
For now the only available mode is "static_plugins" which handles
the behavior of the old function name.
The mode can be enabled by calling
qt6_set_finalizer_mode(${target} ENABLE MODES "static_plugins")
Note that the function is re-tagged as being in Technical Preview.
Ideally we would not need it at all. But we need to provide some
workaround for the limitations of linking Qt static plugins in CMake
on Linux-y platforms that use bfd ld or ld.gold.
The workaround does not work well with dependencies wrapped in
generator expressions which is why we can't confidently advertise it
as a proper solution.
Our hope is that this can be fixed in future upstream CMake versions
and the function can be removed.
See 6fcc272ac9dcf1d6d65de1bdf3138722ba63a902 for details.
Adjust the tests due to the renamed and removed functions.
Amends 19e789bace887105badae83c0a79429bbf8e8221
Amends cdbb390c4a9b8d53cfcfd0884e6720423ce5e126
Amends a25027eecb3829a65543d0e8ab00c74e1b1a21c5
Amends 6fcc272ac9dcf1d6d65de1bdf3138722ba63a902
Amends a3c430f390b379d874916d4c9ff02af5323af1bd
Pick-to: 6.2
Fixes: QTBUG-95169
Task-number: QTBUG-95601
Task-number: QTBUG-95603
Change-Id: I51b85f776ec29fc04fed1a637eba7d1f60609e69
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/corelib/Qt6CoreMacros.cmake')
-rw-r--r-- | src/corelib/Qt6CoreMacros.cmake | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index 4c85873f6b..fe750f8585 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -881,48 +881,52 @@ if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) endfunction() endif() -# This function allows enabling or disabling the finalizer mode of plugin importing in static Qt -# builds. +# This function is currently in Technical Preview. It's signature may change or be removed entirely. + +# This function allows enabling or disabling finalizer modes for a specific target. +# Currently, the only supported finalizer mode is for plugin importing in static Qt builds which +# is called 'static_plugins'. You can enable / disable it by calling +# +# qt6_set_finalizer_mode(${target} ENABLE MODES "static_plugins") +# qt6_set_finalizer_mode(${target} DISABLE MODES "static_plugins") # -# When finalizer mode is enabled, all plugins initializer object libraries are directly linked to -# the given '${target}' (executable or shared library). -# This prevents cycles between Qt provided static libraries and reduces link time, due to the -# libraries not being repeated because they are not part of a cycle anymore. +# When the "static_plugins" finalizer mode is enabled, all plugins initializer object libraries are +# directly linked to the given ${target} (executable or shared library). +# This prevents cycles between Qt provided static libraries and reduces link time, thanks to the +# libraries not being repeated on the link line because they are not part of a cycle anymore. # -# When finalizer mode is disabled, each plugin initializer is propagated via usage requirements -# of its associated module. +# When the finalizer mode is disabled, each plugin initializer is propagated via usage requirements +# of its associated module, which may cause cycles in the current build system implementation. # -# Finalizer mode is enabled by default if: +# The "static_plugins" finalizer mode is enabled by default if: # - the project calls qt_finalize_target explicitly at the end of the project file or # - the project uses qt_add_executable and a CMake version greater than or equal to 3.19 # (which will DEFER CALL qt_finalize_target) -function(qt6_enable_import_plugins_finalizer_mode target enabled) - if(enabled) - set(enabled "TRUE") - else() - set(enabled "FALSE") +function(qt6_set_finalizer_mode target) + cmake_parse_arguments(arg "ENABLE;DISABLE" "" "MODES" ${ARGN}) + if(NOT arg_ENABLE AND NOT arg_DISABLE) + message(FATAL_ERROR "No option was specified whether to enable or disable the modes.") + elseif(arg_ENABLE AND arg_DISABLE) + message(FATAL_ERROR "Both ENABLE and DISABLE options were specified.") + endif() + if(NOT arg_MODES) + message(FATAL_ERROR "No modes were specified in qt6_set_finalizer_mode() call.") endif() - set_property(TARGET "${target}" PROPERTY _qt_static_plugins_use_finalizer_mode "${enabled}") -endfunction() -if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) - function(qt_enable_import_plugins_finalizer_mode) - qt6_enable_import_plugins_finalizer_mode(${ARGV}) - endfunction() -endif() + if(arg_ENABLE) + set(value "TRUE") + elseif(arg_DISABLE) + set(value "FALSE") + endif() -# This function allows enabling or disabling the finalizer mode of resource objects linking in -# static Qt builds. -# It makes sense to manually disable the finalizer of the resource object if you are using -# linkers other than ld, since the dependencies between resource objects and static libraries -# are resolved correctly by them. -function(qt6_enable_object_libraries_finalizer_mode target enabled) - __qt_internal_enable_finalizer_mode(${target} object_libraries ${enabled}) + foreach(mode ${arg_MODES}) + __qt_internal_enable_finalizer_mode("${target}" "${mode}" "${value}") + endforeach() endfunction() if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) - function(qt_enable_object_libraries_finalizer_mode) - qt6_enable_object_libraries_finalizer_mode(${ARGV}) + function(qt_set_finalizer_mode) + qt6_set_finalizer_mode(${ARGV}) endfunction() endif() |