diff options
author | Alexey Edelev <alexey.edelev@qt.io> | 2022-11-03 11:52:33 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-11-04 09:34:02 +0000 |
commit | 0a73fb10005053945571e6cdb0b03d916715c112 (patch) | |
tree | a75d88c01d554987e08001bd869a50b6a870c0cd /src | |
parent | 9fb844a795b80dc3a248a10b07c17cce957ad0f1 (diff) |
Unify the reading of qml imports for Android and desktop platforms
Use the generic way of collecting qml imports for both Android and
desktop platforms.
Amends 2dd17fdf7033434faf7367a5fc8141581dcdf527
Fixes: QTBUG-106940
Change-Id: Ie7888d5848d10f25da7712042a009ae639e5a43c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit 5281cc3ffa3fba670963fc3badac0863182c97cd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/Qt6AndroidQmlMacros.cmake | 20 | ||||
-rw-r--r-- | src/qml/Qt6QmlMacros.cmake | 63 |
2 files changed, 47 insertions, 36 deletions
diff --git a/src/qml/Qt6AndroidQmlMacros.cmake b/src/qml/Qt6AndroidQmlMacros.cmake index 5284c3e71c..787b358975 100644 --- a/src/qml/Qt6AndroidQmlMacros.cmake +++ b/src/qml/Qt6AndroidQmlMacros.cmake @@ -26,18 +26,16 @@ function(_qt_internal_generate_android_qml_deployment_settings out_var target) get_target_property(target_source_dir ${target} SOURCE_DIR) # QML import paths - if(NOT "${QT_QML_OUTPUT_DIRECTORY}" STREQUAL "") - # Need to prepend the default qml module output directory to take precedence - # over other qml import paths. - get_target_property(native_qml_import_paths "${target}" _qt_native_qml_import_paths) - if(native_qml_import_paths) - list(PREPEND native_qml_import_paths "${QT_QML_OUTPUT_DIRECTORY}") - else() - set(native_qml_import_paths "${QT_QML_OUTPUT_DIRECTORY}") - endif() - set_property(TARGET "${target}" PROPERTY - "_qt_native_qml_import_paths" "${native_qml_import_paths}") + _qt_internal_collect_target_qml_import_paths(qml_import_paths ${target}) + get_target_property(native_qml_import_paths "${target}" _qt_native_qml_import_paths) + if(native_qml_import_paths) + list(PREPEND native_qml_import_paths "${qml_import_paths}") + else() + set(native_qml_import_paths "${qml_import_paths}") endif() + list(REMOVE_DUPLICATES native_qml_import_paths) + set_property(TARGET "${target}" PROPERTY + _qt_native_qml_import_paths "${native_qml_import_paths}") _qt_internal_add_android_deployment_multi_value_property(${out_var} "qml-import-paths" ${target} "_qt_native_qml_import_paths") diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake index 29798c2292..b1420b0360 100644 --- a/src/qml/Qt6QmlMacros.cmake +++ b/src/qml/Qt6QmlMacros.cmake @@ -2601,6 +2601,42 @@ function(_qt_internal_get_main_qt_qml_import_paths out_var) set(${out_var} "${qml_import_paths}" PARENT_SCOPE) endfunction() +function(_qt_internal_collect_target_qml_import_paths out_var target) + set(qml_import_paths "") + # Get custom import paths provided during qt_add_qml_module call. + get_target_property(qml_import_path ${target} QT_QML_IMPORT_PATH) + if(qml_import_path) + list(APPEND qml_import_paths ${qml_import_path}) + endif() + + # Facilitate self-import so we can find the qmldir file + get_target_property(module_out_dir ${target} QT_QML_MODULE_OUTPUT_DIRECTORY) + if(module_out_dir) + list(APPEND qml_import_paths "${module_out_dir}") + endif() + + # Find qmldir files we copied to the build directory + if(NOT "${QT_QML_OUTPUT_DIRECTORY}" STREQUAL "") + if(EXISTS "${QT_QML_OUTPUT_DIRECTORY}") + list(APPEND qml_import_paths "${QT_QML_OUTPUT_DIRECTORY}") + endif() + else() + list(APPEND qml_import_paths "${CMAKE_CURRENT_BINARY_DIR}") + endif() + + set(${out_var} "${qml_import_paths}" PARENT_SCOPE) +endfunction() + +function(_qt_internal_collect_qml_import_paths out_var target) + _qt_internal_collect_target_qml_import_paths(qml_import_paths ${target}) + + # Add the Qt import paths last. + _qt_internal_get_main_qt_qml_import_paths(qt_main_import_paths) + list(APPEND qml_import_paths ${qt_main_import_paths}) + + set(${out_var} "${qml_import_paths}" PARENT_SCOPE) +endfunction() + function(_qt_internal_scan_qml_imports target imports_file_var when_to_scan) if(NOT "${ARGN}" STREQUAL "") message(FATAL_ERROR "Unknown/unexpected arguments: ${ARGN}") @@ -2650,31 +2686,8 @@ but this file does not exist. Possible reasons include: -output-file "${imports_file}" ) - set(qml_import_paths "") - # Get custom import paths provided during qt_add_qml_module call. - get_target_property(qml_import_path ${target} QT_QML_IMPORT_PATH) - if(qml_import_path) - list(APPEND qml_import_paths ${qml_import_path}) - endif() - - # Facilitate self-import so we can find the qmldir file - get_target_property(module_out_dir ${target} QT_QML_MODULE_OUTPUT_DIRECTORY) - if(module_out_dir) - list(APPEND qml_import_paths "${module_out_dir}") - endif() - - # Find qmldir files we copied to the build directory - if(NOT "${QT_QML_OUTPUT_DIRECTORY}" STREQUAL "") - if(EXISTS "${QT_QML_OUTPUT_DIRECTORY}") - list(APPEND qml_import_paths "${QT_QML_OUTPUT_DIRECTORY}") - endif() - else() - list(APPEND qml_import_paths "${CMAKE_CURRENT_BINARY_DIR}") - endif() - - # Add the Qt import paths last. - _qt_internal_get_main_qt_qml_import_paths(qt_import_paths) - list(APPEND qml_import_paths ${qt_import_paths}) + _qt_internal_collect_qml_import_paths(qml_import_paths ${target}) + list(REMOVE_DUPLICATES qml_import_paths) # Construct the -importPath arguments. set(import_path_arguments) |