CMake: Semi-handle non-current repo qt modules when creating plugins
In the recent refactoring of qt_internal_add_plugin, a new target
existence check was added when associating a plugin with a qt module.
That check didn't account for a qualified qt module target name.
This failed configuration of qtsvg which checked for the existence of
a namespace-less 'Gui' in a per-repo build.
Make sure to prepend the Qt namespace to the qt module name and also
handle aliased target names.
As a drive-by, add a TODO item to figure out how to link executables
to plugins who's plugin type belong to a different repo, but both the
executable and plugin are built in the current repo.
Amends aa4a1006cb
Fixes: QTBUG-92235
Change-Id: I1c0f83672ab00f4702be9bad9a66ccc35e82f5c8
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 734d2cdbc4ff6db6b3df8fffbb23dbbb565c076b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
ae0fe7d4da
commit
4ffaaaf118
@ -145,24 +145,44 @@ function(qt_internal_add_plugin target)
|
||||
# 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)
|
||||
if(NOT TARGET "${qt_module}")
|
||||
message(FATAL_ERROR "${qt_module} is not a known CMake target")
|
||||
|
||||
set(qt_module_target "${QT_CMAKE_EXPORT_NAMESPACE}::${qt_module}")
|
||||
if(NOT TARGET "${qt_module_target}")
|
||||
message(FATAL_ERROR "Failed to associate Qt plugin with Qt module. ${qt_module_target} is not a known CMake target")
|
||||
endif()
|
||||
|
||||
set_target_properties("${target}" PROPERTIES QT_MODULE "${qt_module}")
|
||||
set(plugin_install_package_suffix "${qt_module}")
|
||||
|
||||
set_property(TARGET "${qt_module}" APPEND PROPERTY QT_PLUGINS "${target}")
|
||||
get_target_property(module_source_dir ${qt_module} SOURCE_DIR)
|
||||
|
||||
get_target_property(aliased_target ${qt_module_target} ALIASED_TARGET)
|
||||
if(aliased_target)
|
||||
set(qt_module_target ${aliased_target})
|
||||
endif()
|
||||
get_target_property(is_imported_qt_module ${qt_module_target} IMPORTED)
|
||||
|
||||
if(NOT is_imported_qt_module)
|
||||
set_property(TARGET "${qt_module_target}" APPEND PROPERTY QT_PLUGINS "${target}")
|
||||
get_target_property(module_source_dir ${qt_module_target} SOURCE_DIR)
|
||||
get_directory_property(module_project_name
|
||||
DIRECTORY ${module_source_dir}
|
||||
DEFINITION PROJECT_NAME
|
||||
)
|
||||
if(module_project_name STREQUAL PROJECT_NAME)
|
||||
set_property(TARGET ${qt_module} APPEND PROPERTY QT_REPO_PLUGINS "${target}")
|
||||
set_property(TARGET ${qt_module} APPEND PROPERTY QT_REPO_PLUGIN_CLASS_NAMES
|
||||
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>"
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
# TODO: If a repo A provides an internal executable E and a plugin P, with the plugin
|
||||
# type belonging to a Qt module defined in a different repo, and executable E needs to
|
||||
# link to plugin P in a static build, currently that won't happen. The executable E
|
||||
# will link to plugins mentioned in the Qt module's QT_REPO_PLUGINS property, but that
|
||||
# property will not list P because the Qt module will be an imported target and won't
|
||||
# have a SOURCE_DIR or PROJECT NAME, so the checks above will not be met.
|
||||
# Figure out how to handle such a scenario.
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Change the configuration file install location for qml plugins into the Qml package location.
|
||||
|
Loading…
Reference in New Issue
Block a user