Fix qt_import_plugins compatibility with Qt 5
Handle versionless plugin names passed to qt_import_plugins. Task-number: QTBUG-74137 Task-number: QTBUG-80477 Change-Id: Ic7fb6e54d2822c7eb58a7874b4a1c137f0c101d9 Reviewed-by: Qt CMake Build Bot Reviewed-by: Cristian Adam <cristian.adam@qt.io>bb10
parent
f53ca8a4fc
commit
b714219fea
|
|
@ -34,6 +34,7 @@ if(NOT @BUILD_SHARED_LIBS@)
|
|||
# The code in here uses the properties defined in qt_import_plugins (Qt6CoreMacros.cmake)
|
||||
foreach(target @qt_plugins@)
|
||||
set(_plugin_target "@INSTALL_CMAKE_NAMESPACE@::${target}")
|
||||
set(_plugin_target_versionless "Qt::${target}")
|
||||
get_target_property(_classname "${_plugin_target}" QT_PLUGIN_CLASS_NAME)
|
||||
if(NOT _classname)
|
||||
message("Warning: plugin ${_plugin_target} has no class name, skipping.")
|
||||
|
|
@ -52,6 +53,8 @@ if(NOT @BUILD_SHARED_LIBS@)
|
|||
|
||||
# INCLUDE
|
||||
set(_plugin_is_whitelisted "$<IN_LIST:${_plugin_target},${_manual_plugins_genex}>")
|
||||
set(_plugin_versionless_is_whitelisted
|
||||
"$<IN_LIST:${_plugin_target_versionless},${_manual_plugins_genex}>")
|
||||
|
||||
# Note: qt_import_plugins sets the QT_PLUGINS_${_plugin_type} to "-"
|
||||
# when excluding it with EXCLUDE_BY_TYPE,
|
||||
|
|
@ -61,7 +64,11 @@ if(NOT @BUILD_SHARED_LIBS@)
|
|||
"$<NOT:" # EXCLUDE
|
||||
"$<IN_LIST:${_plugin_target},${_no_plugins_genex}>"
|
||||
">,"
|
||||
# excludes both plugins targeted by EXCLUDE_BY_TYPE and not included in INCLUDE_BY_TYPE
|
||||
"$<NOT:"
|
||||
"$<IN_LIST:${_plugin_target_versionless},${_no_plugins_genex}>"
|
||||
">,"
|
||||
# Excludes both plugins targeted by EXCLUDE_BY_TYPE and not included in
|
||||
# INCLUDE_BY_TYPE.
|
||||
"$<STREQUAL:,$<GENEX_EVAL:$<TARGET_PROPERTY:QT_PLUGINS_${_plugin_type}>>>"
|
||||
">"
|
||||
)
|
||||
|
|
@ -75,6 +82,14 @@ if(NOT @BUILD_SHARED_LIBS@)
|
|||
">"
|
||||
">"
|
||||
)
|
||||
string(CONCAT _plugin_versionless_is_in_type_whitelist
|
||||
"$<IN_LIST:"
|
||||
"${_plugin_target_versionless},"
|
||||
"$<GENEX_EVAL:"
|
||||
"$<TARGET_PROPERTY:QT_PLUGINS_${_plugin_type}>"
|
||||
">"
|
||||
">"
|
||||
)
|
||||
|
||||
# Complete condition that defines whether a static plugin is linked
|
||||
string(CONCAT _plugin_condition
|
||||
|
|
@ -82,7 +97,9 @@ if(NOT @BUILD_SHARED_LIBS@)
|
|||
"${_build_allow_plugin_link_rules_genex},"
|
||||
"$<OR:"
|
||||
"${_plugin_is_whitelisted},"
|
||||
"${_plugin_versionless_is_whitelisted},"
|
||||
"${_plugin_is_in_type_whitelist},"
|
||||
"${_plugin_versionless_is_in_type_whitelist},"
|
||||
"$<AND:"
|
||||
"${_default_plugins_are_enabled_wrapped},"
|
||||
"${_plugin_is_default},"
|
||||
|
|
|
|||
|
|
@ -478,10 +478,33 @@ function(add_qt_gui_executable target)
|
|||
endif()
|
||||
endfunction()
|
||||
|
||||
function(_qt_get_plugin_name_with_version target out_var)
|
||||
string(REGEX REPLACE "^Qt::(.+)" "Qt${QT_DEFAULT_MAJOR_VERSION}::\\1"
|
||||
qt_plugin_with_version "${target}")
|
||||
if(TARGET "${qt_plugin_with_version}")
|
||||
set("${out_var}" "${qt_plugin_with_version}" PARENT_SCOPE)
|
||||
else()
|
||||
set("${out_var}" "" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
macro(_qt_import_plugin target plugin)
|
||||
get_target_property(plugin_class_name "${plugin}" QT_PLUGIN_CLASS_NAME)
|
||||
if(plugin_class_name)
|
||||
set_property(TARGET "${target}" APPEND PROPERTY QT_PLUGINS "${plugin}")
|
||||
set(_final_plugin_name "${plugin}")
|
||||
if(NOT TARGET "${plugin}")
|
||||
_qt_get_plugin_name_with_version("${plugin}" _qt_plugin_with_version_name)
|
||||
if(TARGET "${_qt_plugin_with_version_name}")
|
||||
set(_final_plugin_name "${_qt_plugin_with_version_name}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT TARGET "${_final_plugin_name}")
|
||||
message(
|
||||
"Warning: plug-in ${_final_plugin_name} is not known to the current Qt installation.")
|
||||
else()
|
||||
get_target_property(_plugin_class_name "${_final_plugin_name}" QT_PLUGIN_CLASS_NAME)
|
||||
if(_plugin_class_name)
|
||||
set_property(TARGET "${target}" APPEND PROPERTY QT_PLUGINS "${plugin}")
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
|
@ -535,7 +558,10 @@ function(qt6_import_plugins target)
|
|||
message(FATAL_ERROR "qt_import_plugins: invalid syntax for INCLUDE_BY_TYPE")
|
||||
endif()
|
||||
|
||||
if(TARGET "${_arg}")
|
||||
# Check if passed plugin target name is a version-less one, and make a version-full
|
||||
# one.
|
||||
_qt_get_plugin_name_with_version("${_arg}" qt_plugin_with_version)
|
||||
if(TARGET "${_arg}" OR TARGET "${qt_plugin_with_version}")
|
||||
set_property(TARGET "${target}" APPEND PROPERTY "QT_PLUGINS_${_current_type}" "${_arg}")
|
||||
else()
|
||||
message("Warning: plug-in ${_arg} is not known to the current Qt installation.")
|
||||
|
|
|
|||
Loading…
Reference in New Issue