summaryrefslogtreecommitdiffstats
path: root/src/corelib/Qt6CoreMacros.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-01-22 16:28:57 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-01-27 11:59:51 +0000
commitb714219fea567ff4ad7d84972704dbed8f5b4cf3 (patch)
tree4f14ae00fbb585b2e87e09041fb14b0e6f89b655 /src/corelib/Qt6CoreMacros.cmake
parentf53ca8a4fc1e82d1c4802e387abe759b53f74b62 (diff)
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>
Diffstat (limited to 'src/corelib/Qt6CoreMacros.cmake')
-rw-r--r--src/corelib/Qt6CoreMacros.cmake34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index ff1e1d1910..03be9488c6 100644
--- a/src/corelib/Qt6CoreMacros.cmake
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -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.")