diff options
author | Alexey Edelev <alexey.edelev@qt.io> | 2024-01-02 14:37:38 +0100 |
---|---|---|
committer | Alexey Edelev <alexey.edelev@qt.io> | 2024-01-22 12:00:44 +0100 |
commit | 7d26fdbe1cd7a26312de4fc414c15afbd4f158e1 (patch) | |
tree | 0f48b01b22bcb9178d3fd894e85fb04b7f19c58f | |
parent | 9452e8d7dbb019aed1970795e46d1476833e89d4 (diff) |
Change the way tests and examples query the qmldir file from QML plugin targets
Use qt6_query_qml_module to get path to qmldir, but not TARGET_FILE_DIR.
This is more accurate way.
Pick-to: 6.5
Fixes: QTBUG-120479
Change-Id: I4b7f7bf3b7f69c15871e400af3e7ae945a9bfdf0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit d276d025a8f5eece16ad6c08fb552ab133fae615)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 5e60f6d1417aa3a9a4059eb3131b54c43b6af5f6)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
5 files changed, 16 insertions, 19 deletions
diff --git a/examples/quick/customitems/painteditem/CMakeLists.txt b/examples/quick/customitems/painteditem/CMakeLists.txt index b9f608da0f..d97db9b03e 100644 --- a/examples/quick/customitems/painteditem/CMakeLists.txt +++ b/examples/quick/customitems/painteditem/CMakeLists.txt @@ -45,7 +45,5 @@ install(TARGETS painteditemexample include(../../shared/QtBundleQmlModuleForMacOS.cmake) set(app_target "painteditemexample") -set(qml_plugin_target "qmltextballoon") -set(qml_module_uri "TextBalloon") -add_qml_module_to_macos_app_bundle( - "${app_target}" "${qml_plugin_target}" "${qml_module_uri}") +set(qml_module "qmltextballoon") +add_qml_module_to_macos_app_bundle("${app_target}" "${qml_module}") diff --git a/examples/quick/shared/CMakeLists.txt b/examples/quick/shared/CMakeLists.txt index 704d148025..629a35539e 100644 --- a/examples/quick/shared/CMakeLists.txt +++ b/examples/quick/shared/CMakeLists.txt @@ -42,10 +42,8 @@ include(QtBundleQmlModuleForMacOS.cmake) # Puts the shared qml module plugin and qmldir into the macOS app bundle directory. # Only call this function if your main project has the MACOSX_BUNDLE option set. function(bundle_shared app_target) - set(qml_plugin_target "${PROJECT_NAME}_shared") - set(qml_module_uri "shared") - add_qml_module_to_macos_app_bundle( - "${app_target}" "${qml_plugin_target}" "${qml_module_uri}") + set(qml_module_target "${PROJECT_NAME}_shared") + add_qml_module_to_macos_app_bundle("${app_target}" "${qml_module_target}") endfunction() set(INSTALL_SHAREDDIR "${INSTALL_EXAMPLESDIR}/quick/${PROJECT_NAME}/shared") diff --git a/examples/quick/shared/QtBundleQmlModuleForMacOS.cmake b/examples/quick/shared/QtBundleQmlModuleForMacOS.cmake index 06d1487323..767b64bbfc 100644 --- a/examples/quick/shared/QtBundleQmlModuleForMacOS.cmake +++ b/examples/quick/shared/QtBundleQmlModuleForMacOS.cmake @@ -1,12 +1,18 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause -function(add_qml_module_to_macos_app_bundle app_target qml_plugin_target qml_module_uri) +function(add_qml_module_to_macos_app_bundle app_target qml_module) if(QT6_IS_SHARED_LIBS_BUILD AND APPLE) # The application's main.cpp adds an explicit QML import path to look for qml module plugins # under a PlugIns subdirectory of a macOS app bundle. # Copy the qmldir and shared library qml plugin. + qt6_query_qml_module(${qml_module} + QMLDIR qmldir_file + PLUGIN_TARGET qml_plugin_target + URI qml_module_uri + ) + # Ensure the executable depends on the plugin so the plugin is copied # only after it was built. add_dependencies(${app_target} ${qml_plugin_target}) @@ -17,9 +23,6 @@ function(add_qml_module_to_macos_app_bundle app_target qml_plugin_target qml_mod set(dest_module_dir_in_app_bundle "${app_dir}/../PlugIns/${escaped_uri}") - set(qml_plugin_dir "$<TARGET_FILE_DIR:${qml_plugin_target}>") - set(qmldir_file "${qml_plugin_dir}/qmldir") - add_custom_command(TARGET ${app_target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${dest_module_dir_in_app_bundle} COMMAND ${CMAKE_COMMAND} -E copy_if_different diff --git a/examples/quickcontrols/attachedstyleproperties/CMakeLists.txt b/examples/quickcontrols/attachedstyleproperties/CMakeLists.txt index 5c5536aace..159395307f 100644 --- a/examples/quickcontrols/attachedstyleproperties/CMakeLists.txt +++ b/examples/quickcontrols/attachedstyleproperties/CMakeLists.txt @@ -46,7 +46,5 @@ install(TARGETS attachedstylepropertiesexample include(../../quick/shared/QtBundleQmlModuleForMacOS.cmake) set(app_target "attachedstylepropertiesexample") -set(qml_plugin_target "MyStyleplugin") -set(qml_module_uri "MyStyle") -add_qml_module_to_macos_app_bundle( - "${app_target}" "${qml_plugin_target}" "${qml_module_uri}") +set(qml_module_target "MyStyle") +add_qml_module_to_macos_app_bundle("${app_target}" "${qml_module_target}") diff --git a/examples/quickcontrols/wearable/CMakeLists.txt b/examples/quickcontrols/wearable/CMakeLists.txt index c293d64ef2..eccbea20aa 100644 --- a/examples/quickcontrols/wearable/CMakeLists.txt +++ b/examples/quickcontrols/wearable/CMakeLists.txt @@ -54,6 +54,6 @@ install(TARGETS wearableexample include(../../quick/shared/QtBundleQmlModuleForMacOS.cmake) set(app_target "wearableexample") -add_qml_module_to_macos_app_bundle("${app_target}" "wearable" "Wearable") -add_qml_module_to_macos_app_bundle("${app_target}" "wearablesettings" "WearableSettings") -add_qml_module_to_macos_app_bundle("${app_target}" "wearablestyle" "WearableStyle") +add_qml_module_to_macos_app_bundle("${app_target}" "wearable") +add_qml_module_to_macos_app_bundle("${app_target}" "wearablesettings") +add_qml_module_to_macos_app_bundle("${app_target}" "wearablestyle") |