diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-04-07 12:00:09 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-04-13 09:43:30 +0200 |
commit | 6a5d90f7e8f88c5951d661c849cf6bfe04191ea1 (patch) | |
tree | b64e147364df7265270780698e916bb962304264 | |
parent | d2b52405f5ffa7e11b1a8a1540b173ed23b908e4 (diff) |
CMake: Fix duplicate symbol errors in Windows static super builds
qt_internal_add_executable has some special logic to link static
plugins in order to avoid issues with link cycles on exported
Qt module targets. This logic does not take into account if a plugin
is a default plugin.
On windows this caused duplicate symbol linking issues in static super
builds, because both qwindows and qdirect2d define a subset of
the same symbols.
Make sure to only link to default static plugins.
This will skip linking to qdirect2d because it's not a default qpa
plugin and thus avoid linker issues.
Amends 5807e1ae8168a5702ad0f6890d2b35223cfebdee
Fixes: QTBUG-92451
Change-Id: I56df2ce0201625088417de53038642518c1d3bbd
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit ededf3914297aca62e1d257175305cab5dbf6da2)
-rw-r--r-- | cmake/QtPluginHelpers.cmake | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/cmake/QtPluginHelpers.cmake b/cmake/QtPluginHelpers.cmake index 36c1335f6c..2e1ede73cb 100644 --- a/cmake/QtPluginHelpers.cmake +++ b/cmake/QtPluginHelpers.cmake @@ -142,6 +142,23 @@ function(qt_internal_add_plugin target) unset(plugin_install_package_suffix) + # The generic plugins should be enabled by default. + # But platform plugins should always be disabled by default, and only one is enabled + # based on the platform (condition specified in arg_DEFAULT_IF). + if(plugin_type_escaped STREQUAL "platforms") + set(_default_plugin 0) + else() + set(_default_plugin 1) + endif() + + if (DEFINED arg_DEFAULT_IF) + if (NOT ${arg_DEFAULT_IF}) + set(_default_plugin 0) + else() + set(_default_plugin 1) + endif() + endif() + # Save the Qt module in the plug-in's properties and vice versa if(NOT plugin_type_escaped STREQUAL "qml_plugin") qt_internal_get_module_for_plugin("${target}" "${plugin_type_escaped}" qt_module) @@ -168,7 +185,10 @@ function(qt_internal_add_plugin target) DIRECTORY ${module_source_dir} DEFINITION PROJECT_NAME ) - if(module_project_name STREQUAL PROJECT_NAME) + + # When linking static plugins with the special logic in qt_internal_add_executable, + # make sure to skip non-default plugins. + if(module_project_name STREQUAL PROJECT_NAME AND _default_plugin) set_property(TARGET ${qt_module_target} APPEND PROPERTY _qt_repo_plugins "${target}") set_property(TARGET ${qt_module_target} APPEND PROPERTY _qt_repo_plugin_class_names "$<TARGET_PROPERTY:${target},QT_PLUGIN_CLASS_NAME>" @@ -197,23 +217,6 @@ function(qt_internal_add_plugin target) _qt_plugin_install_package_suffix "${plugin_install_package_suffix}") endif() - # The generic plugins should be enabled by default. - # But platform plugins should always be disabled by default, and only one is enabled - # based on the platform (condition specified in arg_DEFAULT_IF). - if(plugin_type_escaped STREQUAL "platforms") - set(_default_plugin 0) - else() - set(_default_plugin 1) - endif() - - if (DEFINED arg_DEFAULT_IF) - if (NOT ${arg_DEFAULT_IF}) - set(_default_plugin 0) - else() - set(_default_plugin 1) - endif() - endif() - add_dependencies(qt_plugins "${target}") if(arg_TYPE STREQUAL "platforms") add_dependencies(qpa_plugins "${target}") |