diff --git a/cmake/QtPlugins.cmake.in b/cmake/QtPlugins.cmake.in index 09a2f40414..405d5f37b9 100644 --- a/cmake/QtPlugins.cmake.in +++ b/cmake/QtPlugins.cmake.in @@ -1,6 +1,6 @@ include_guard(DIRECTORY) @QT_MODULE_PLUGIN_INCLUDES@ -if(NOT @BUILD_SHARED_LIBS@ AND NOT QT_NO_CREATE_TARGETS) +if(NOT QT_NO_CREATE_TARGETS AND NOT QT_SKIP_AUTO_PLUGIN_INCLUSION) __qt_internal_include_plugin_packages(@QT_MODULE@) endif() diff --git a/cmake/QtPostProcess.cmake b/cmake/QtPostProcess.cmake index 0cb0edf1c6..77b226718b 100644 --- a/cmake/QtPostProcess.cmake +++ b/cmake/QtPostProcess.cmake @@ -2,7 +2,7 @@ include(QtPostProcessHelpers) qt_internal_create_depends_files() qt_generate_build_internals_extra_cmake_code() -qt_internal_create_plugins_files() +qt_internal_create_plugins_auto_inclusion_files() qt_internal_create_config_file_for_standalone_tests() # Needs to run after qt_internal_create_depends_files. diff --git a/cmake/QtPostProcessHelpers.cmake b/cmake/QtPostProcessHelpers.cmake index 544f02c9d8..a655c11614 100644 --- a/cmake/QtPostProcessHelpers.cmake +++ b/cmake/QtPostProcessHelpers.cmake @@ -401,14 +401,11 @@ function(qt_internal_create_depends_files) endforeach() endfunction() -# This function creates the QtPlugins.cmake used to list all -# the plug-in target files. -function(qt_internal_create_plugins_files) - # The plugins cmake configuration is only needed for static builds. Dynamic builds don't need - # the application to link against plugins at build time. - if(QT_BUILD_SHARED_LIBS) - return() - endif() +# This function creates QtPlugins.cmake files used to include all +# the plugin Config files that belong to that module. +function(qt_internal_create_plugins_auto_inclusion_files) + # For static library builds, the plugin targets need to be available for linking. + # For shared library builds, the plugin targets are useful for deployment purposes. qt_internal_get_qt_repo_known_modules(repo_known_modules) set(modules_with_plugins "") diff --git a/cmake/QtPublicPluginHelpers.cmake b/cmake/QtPublicPluginHelpers.cmake index 90d784d88e..6dfaead755 100644 --- a/cmake/QtPublicPluginHelpers.cmake +++ b/cmake/QtPublicPluginHelpers.cmake @@ -461,9 +461,12 @@ function(__qt_internal_include_plugin_packages target) list(APPEND "QT_ALL_PLUGINS_FOUND_BY_FIND_PACKAGE_${__plugin_type}" "${plugin_target}") - __qt_internal_add_static_plugin_linkage("${plugin_target}" "${_module_target}") - __qt_internal_add_static_plugin_import_macro( - "${plugin_target}" ${_module_target} "${target}") + # Auto-linkage should be set up only for static library builds. + if(NOT QT6_IS_SHARED_LIBS_BUILD) + __qt_internal_add_static_plugin_linkage("${plugin_target}" "${_module_target}") + __qt_internal_add_static_plugin_import_macro( + "${plugin_target}" ${_module_target} "${target}") + endif() endforeach() set("QT_ALL_PLUGINS_FOUND_BY_FIND_PACKAGE_${__plugin_type}"