b104bedea1
Extract common static plugin handling functionality into a separate QtPublicPluginHelpers.cmake file which is loaded by the Qt6 package. Split the code into smaller functions that will be re-used by each templated QtPlugins.cmake.in file, rather than copy pasting the same code into each QtFooPlugins.cmake file. As a drive-by, handle QtFeatures.cmake and QtFeaturesCommon.cmake as public helper files just like QtPublicPluginHelpers.cmake. This makes it clearer that the functions are available outside the internal Qt build and also provides a way for not dumping new helper functions into Qt6CoreMacros.cmake. Task-number: QTBUG-92933 Change-Id: Id816ef009b4fac1cd317d3ef23f21b3530028067 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
62 lines
2.4 KiB
CMake
62 lines
2.4 KiB
CMake
include_guard(DIRECTORY)
|
|
@QT_MODULE_PLUGIN_INCLUDES@
|
|
|
|
# Use a function to hide all the temporary variables we use so they don't leak
|
|
# out into the consuming scope
|
|
function(__qt_internal_add_static_plugins_once)
|
|
set(_module_target "@INSTALL_CMAKE_NAMESPACE@::@QT_MODULE@")
|
|
set(_qt_plugins "")
|
|
|
|
# Properties can't be set on aliased targets, so make sure to unalias the target. This is needed
|
|
# when Qt examples are built as part of the Qt build itself.
|
|
get_target_property(_aliased_target ${_module_target} ALIASED_TARGET)
|
|
if(_aliased_target)
|
|
set(_module_target ${_aliased_target})
|
|
endif()
|
|
|
|
# Include all PluginConfig.cmake files and update the QT_PLUGINS property of the module.
|
|
file(GLOB _qt_plugin_config_files "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@*PluginConfig.cmake")
|
|
foreach(_config_file ${_qt_plugin_config_files})
|
|
string(REGEX REPLACE "^.*/@INSTALL_CMAKE_NAMESPACE@(.*Plugin)Config.cmake$" "\\1" _qt_plugin "${_config_file}")
|
|
include("${_config_file}")
|
|
if(TARGET "@INSTALL_CMAKE_NAMESPACE@::${_qt_plugin}")
|
|
list(APPEND _qt_plugins ${_qt_plugin})
|
|
endif()
|
|
endforeach()
|
|
set_property(TARGET ${_module_target} PROPERTY QT_PLUGINS ${_qt_plugins})
|
|
|
|
get_target_property(_have_added_plugins_already ${_module_target} __qt_internal_plugins_added)
|
|
if(_have_added_plugins_already)
|
|
return()
|
|
endif()
|
|
|
|
foreach(plugin_target ${_qt_plugins})
|
|
__qt_internal_plugin_get_plugin_type("${plugin_target}" __has_plugin_type __plugin_type)
|
|
if(NOT __has_plugin_type)
|
|
continue()
|
|
endif()
|
|
|
|
__qt_internal_plugin_has_class_name("${plugin_target}" __has_class_name)
|
|
if(NOT __has_class_name)
|
|
continue()
|
|
endif()
|
|
|
|
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} "@QT_MODULE@")
|
|
endforeach()
|
|
|
|
set("QT_ALL_PLUGINS_FOUND_BY_FIND_PACKAGE_${__plugin_type}"
|
|
"${QT_ALL_PLUGINS_FOUND_BY_FIND_PACKAGE_${__plugin_type}}"
|
|
PARENT_SCOPE
|
|
)
|
|
|
|
set_target_properties(${_module_target} PROPERTIES __qt_internal_plugins_added TRUE)
|
|
endfunction()
|
|
|
|
if(NOT @BUILD_SHARED_LIBS@ AND NOT QT_NO_CREATE_TARGETS)
|
|
__qt_internal_add_static_plugins_once()
|
|
endif()
|