Consider the qt_internal_extend_target calls when adding deps on qpa_default_plugins

Applications not necessarly link QtGui module in
qt_internal_add_executable. They still may add link it in followoup
qt_internal_extend_target calls. We should consider this when adding
dependencies on qpa_default_plugins to the internal executables.

Pick-to: 6.7
Change-Id: Icc413bd35b631b3a356e4033faab4e6c01b29a60
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2024-03-28 11:03:25 +01:00
parent 1e8a36e360
commit c5be402651
2 changed files with 11 additions and 11 deletions

View File

@ -207,15 +207,6 @@ function(qt_internal_add_executable name)
ADDITIONAL_INSTALL_ARGS ${additional_install_args})
qt_internal_install_pdb_files(${name} "${arg_INSTALL_DIRECTORY}")
endif()
# If linking against Gui, make sure to also build the default QPA plugin.
# This makes the experience of an initial Qt configuration to build and run one single
# test / executable nicer.
get_target_property(linked_libs "${name}" LINK_LIBRARIES)
if(linked_libs MATCHES "(^|;)(${QT_CMAKE_EXPORT_NAMESPACE}::|Qt::)?Gui($|;)" AND
TARGET qpa_default_plugins)
add_dependencies("${name}" qpa_default_plugins)
endif()
endfunction()
# This function compiles the target at configure time the very first time and creates the custom

View File

@ -277,9 +277,18 @@ function(qt_internal_extend_target target)
_qt_extra_linker_script_exports "${arg_EXTRA_LINKER_SCRIPT_EXPORTS}")
endif()
# For executables collect static plugins that these targets depend on.
if(is_executable)
qt_internal_import_plugins(${target} ${arg_PUBLIC_LIBRARIES} ${arg_LIBRARIES})
# If linking against Gui, make sure to also build the default QPA plugin.
# This makes the experience of an initial Qt configuration to build and run one single
# test / executable nicer.
set(linked_libs ${arg_PUBLIC_LIBRARIES} ${arg_LIBRARIES})
if(linked_libs MATCHES "(^|;)(${QT_CMAKE_EXPORT_NAMESPACE}::|Qt::)?Gui($|;)" AND
TARGET qpa_default_plugins)
add_dependencies("${target}" qpa_default_plugins)
endif()
# For executables collect static plugins that these targets depend on.
qt_internal_import_plugins(${target} ${linked_libs})
endif()
endfunction()