diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 49681090892..6375ffdca78 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -2731,8 +2731,12 @@ function(qt_internal_add_plugin target) # Derive the class name from the target name if it's not explicitly specified. # Don't set it for qml plugins though. set(plugin_class_name "") - if (NOT arg_CLASS_NAME AND NOT "${plugin_type_escaped}" STREQUAL "qml_plugin") - set(plugin_class_name "${target}") + if (NOT "${plugin_type_escaped}" STREQUAL "qml_plugin") + if (NOT arg_CLASS_NAME) + set(plugin_class_name "${target}") + else() + set(plugin_class_name "${arg_CLASS_NAME}") + endif() endif() qt_internal_check_directory_or_type(OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}" "${arg_TYPE}" diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index 2e7022c1167..d3e13fffa9b 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -1140,6 +1140,7 @@ function(qt6_add_plugin target) cmake_parse_arguments(arg "STATIC" "OUTPUT_NAME" + "CLASS_NAME" "" ${ARGN} ) @@ -1168,6 +1169,15 @@ function(qt6_add_plugin target) ) endif() + # Derive the class name from the target name if it's not explicitly specified. + set(plugin_class_name "") + if (NOT arg_CLASS_NAME) + set(plugin_class_name "${target}") + else() + set(plugin_class_name "${arg_CLASS_NAME}") + endif() + set_target_properties(${target} PROPERTIES QT_PLUGIN_CLASS_NAME "${plugin_class_name}") + set(static_plugin_define "") if (arg_STATIC) set(static_plugin_define "QT_STATICPLUGIN")