Only generate and add static plugin imports once per module target
Projects may call find_package(Qt6 ...) multiple times. When enabling examples and tests, this happens a lot. For a statically built Qt, for modules that have plugins (e.g. Gui), every time the module's config file was loaded, it was generating and adding another copy of the import plugin sources to the module target. These accumulated and created many duplicates, which in turn blew out generation time and made the build very inefficient. This change checks whether the import plugin sources have already been processed for the module target and ensures they are only added once. It records its status on the target itself so that both local and global targets are supported. Fixes: QTBUG-90465 Change-Id: I1f45b1ee771a933ee755d44f1e983d6d9113dad0 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
af0fa5cffe
commit
f0ccdbb439
@ -1,7 +1,9 @@
|
||||
include_guard(DIRECTORY)
|
||||
@QT_MODULE_PLUGIN_INCLUDES@
|
||||
|
||||
if(NOT @BUILD_SHARED_LIBS@)
|
||||
# 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 "")
|
||||
|
||||
@ -20,7 +22,11 @@ if(NOT @BUILD_SHARED_LIBS@)
|
||||
if(_aliased_target)
|
||||
set(_module_target ${_aliased_target})
|
||||
endif()
|
||||
unset(_aliased_target)
|
||||
|
||||
get_target_property(_have_added_plugins_already ${_module_target} __qt_internal_plugins_added)
|
||||
if(_have_added_plugins_already)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(_default_plugins_are_enabled "$<NOT:$<STREQUAL:$<GENEX_EVAL:$<TARGET_PROPERTY:QT_DEFAULT_PLUGINS>>,0>>")
|
||||
# Make sure to boolify the result of the expression, in case if the returned property value
|
||||
@ -61,6 +67,10 @@ if(NOT @BUILD_SHARED_LIBS@)
|
||||
endif()
|
||||
|
||||
list(APPEND "QT_ALL_PLUGINS_FOUND_BY_FIND_PACKAGE_${_plugin_type}" "${target}")
|
||||
set("QT_ALL_PLUGINS_FOUND_BY_FIND_PACKAGE_${_plugin_type}"
|
||||
"${QT_ALL_PLUGINS_FOUND_BY_FIND_PACKAGE_${_plugin_type}}"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
set(_plugin_is_default "$<TARGET_PROPERTY:${_plugin_target},QT_DEFAULT_PLUGIN>")
|
||||
|
||||
@ -142,4 +152,10 @@ if(NOT @BUILD_SHARED_LIBS@)
|
||||
target_sources(${_module_target} INTERFACE
|
||||
"$<${_plugin_condition}:${_generated_qt_plugin_file_name}>")
|
||||
endforeach()
|
||||
|
||||
set_target_properties(${_module_target} PROPERTIES __qt_internal_plugins_added TRUE)
|
||||
endfunction()
|
||||
|
||||
if(NOT @BUILD_SHARED_LIBS@)
|
||||
__qt_internal_add_static_plugins_once()
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue
Block a user