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-15 21:25:12 +0100 |
commit | d276d025a8f5eece16ad6c08fb552ab133fae615 (patch) | |
tree | 7ecf52977bf613e5d51085aafdb9527de13e61f8 /examples/quick | |
parent | 098ef8089a85719eb6affb5a5cc7e81112102593 (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 6.6 6.7
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>
Diffstat (limited to 'examples/quick')
-rw-r--r-- | examples/quick/customitems/painteditem/CMakeLists.txt | 6 | ||||
-rw-r--r-- | examples/quick/shared/CMakeLists.txt | 6 | ||||
-rw-r--r-- | examples/quick/shared/QtBundleQmlModuleForMacOS.cmake | 11 |
3 files changed, 11 insertions, 12 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 b98b0b1ccd..7eae76cf44 100644 --- a/examples/quick/shared/CMakeLists.txt +++ b/examples/quick/shared/CMakeLists.txt @@ -41,10 +41,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 |