aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@qt.io>2021-07-26 11:42:12 +1000
committerCraig Scott <craig.scott@qt.io>2021-07-26 20:41:10 +1000
commitbdcb1d702da3d27b51135e4ecc11f89b74bd96a3 (patch)
treef17dd1e0721c6d15539f5e9931b5231899967b8b /src
parente624271fd36055bc3237ae7a3d6006cdecb9fd74 (diff)
Make CLASS_NAME default match the documentation for qt6_add_qml_plugin
The implementation did not obtain the class name from the backing target, but it should have. Instead, it was considering an internal target property on the plugin target itself, if it already existed. That was a leftover from earlier work where the plugin target may have been created directly by calling qt_add_plugin(), but it doesn't match the behavior we document or support. Simplify the implementation and make it match the documented behavior. Pick-to: 6.2 Change-Id: Icd9ee1167e189715e8aff57f147734a2476f630c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/Qt6QmlMacros.cmake31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake
index d4109900d7..fe6078e58b 100644
--- a/src/qml/Qt6QmlMacros.cmake
+++ b/src/qml/Qt6QmlMacros.cmake
@@ -834,6 +834,15 @@ function(qt6_add_qml_plugin target)
_qt_internal_get_escaped_uri("${arg_URI}" escaped_uri)
+ if(NOT arg_CLASS_NAME)
+ if(NOT "${arg_BACKING_TARGET}" STREQUAL "")
+ get_target_property(arg_CLASS_NAME ${target} QT_QML_MODULE_CLASS_NAME)
+ endif()
+ if(NOT arg_CLASS_NAME)
+ _qt_internal_compute_qml_plugin_class_name_from_uri("${arg_URI}" arg_CLASS_NAME)
+ endif()
+ endif()
+
if(TARGET ${target})
get_target_property(target_type ${target} TYPE)
if(target_type STREQUAL "EXECUTABLE")
@@ -846,17 +855,13 @@ function(qt6_add_qml_plugin target)
)
endif()
endforeach()
- get_target_property(class_name ${target} QT_PLUGIN_CLASS_NAME)
- if(class_name)
- if(arg_CLASS_NAME AND NOT arg_CLASS_NAME STREQUAL class_name)
- message(FATAL_ERROR
- "CLASS_NAME was specified, but an existing target with a "
- "different class name was also given"
- )
- endif()
- set(arg_CLASS_NAME ${class_name})
- elseif(NOT arg_CLASS_NAME)
- _qt_internal_compute_qml_plugin_class_name_from_uri("${arg_URI}" arg_CLASS_NAME)
+
+ get_target_property(existing_class_name ${target} QT_PLUGIN_CLASS_NAME)
+ if(existing_class_name AND NOT existing_class_name STREQUAL arg_CLASS_NAME)
+ message(FATAL_ERROR
+ "An existing target was given, but it has a different class name "
+ "(${existing_class_name}) to that being used here (${arg_CLASS_NAME})"
+ )
endif()
else()
if(arg_STATIC AND arg_SHARED)
@@ -871,10 +876,6 @@ function(qt6_add_qml_plugin target)
set(lib_type SHARED)
endif()
- if(NOT arg_CLASS_NAME)
- _qt_internal_compute_qml_plugin_class_name_from_uri("${arg_URI}" arg_CLASS_NAME)
- endif()
-
qt6_add_plugin(${target} ${lib_type}
TYPE qml_plugin
CLASS_NAME ${arg_CLASS_NAME}