From f722c5eca06765327bbc08e69244b3e69536f2a7 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 14 Aug 2020 20:40:51 +0200 Subject: CMake: Adjust naming of Qt Qml plugins for Android The names are identical to the qmake ones now, following the scheme that the plugin file name should contain the TARGET_PATH, aka the directory path of the plugin, encoded in the file name itself because that's how the Android Qml plugin loader expects them. A second change is needed to pass the correct library suffix as the define, so that the Qml plugin loader actually finds them. After that, the following error goes away. libemitters_x86: qrc:/particles/emitters/emitters.qml:51:1: module "QtQuick" plugin "qtquick2plugin" not found import QtQuick 2.0 Task-number: QTBUG-85399 Change-Id: I16b9f877db3e5c8266429772a44231f1a356515c Reviewed-by: Joerg Bornemann --- src/qml/Qt6QmlMacros.cmake | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/qml') diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake index d16e48c420..07c99200af 100644 --- a/src/qml/Qt6QmlMacros.cmake +++ b/src/qml/Qt6QmlMacros.cmake @@ -170,6 +170,26 @@ function(qt6_add_qml_module target) string(REPLACE "." "/" arg_TARGET_PATH ${arg_URI}) endif() + if (ANDROID) + # Adjust Qml plugin names on Android similar to qml_plugin.prf which calls + # $$qt5LibraryTarget($$TARGET, "qml/$$TARGETPATH/"). + # Example plugin names: + # qtdeclarative + # TARGET_PATH: QtQml/Models + # file name: libqml_QtQml_Models_modelsplugin_arm64-v8a.so + # qtquickcontrols2 + # TARGET_PATH: QtQuick/Controls.2/Material + # file name: + # libqml_QtQuick_Controls.2_Material_qtquickcontrols2materialstyleplugin_arm64-v8a.so + string(REPLACE "/" "_" android_plugin_name_infix_name "${arg_TARGET_PATH}") + + set(final_android_qml_plugin_name "qml_${android_plugin_name_infix_name}_${target}") + set_target_properties(${target} + PROPERTIES + LIBRARY_OUTPUT_NAME "${final_android_qml_plugin_name}" + ) + endif() + if (NOT arg_RESOURCE_PREFIX) set(arg_RESOURCE_PREFIX "/org.qt-project/imports") endif() -- cgit v1.2.3