aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2022-11-03 11:52:33 +0100
committerAlexey Edelev <alexey.edelev@qt.io>2022-11-03 15:56:07 +0100
commit5281cc3ffa3fba670963fc3badac0863182c97cd (patch)
tree47e5124d2b0b50e486b93f94f1f5229180fbe61f /src/qml
parentd7d44783cee166e0dd0c24b56478ab6d4c0c6cdc (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 Pick-to: 6.4 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>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/Qt6AndroidQmlMacros.cmake20
-rw-r--r--src/qml/Qt6QmlMacros.cmake63
2 files changed, 47 insertions, 36 deletions
diff --git a/src/qml/Qt6AndroidQmlMacros.cmake b/src/qml/Qt6AndroidQmlMacros.cmake
index d3324176c0..0463fcf0a5 100644
--- a/src/qml/Qt6AndroidQmlMacros.cmake
+++ b/src/qml/Qt6AndroidQmlMacros.cmake
@@ -29,18 +29,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 cef73c1cbd..faa08c6f1d 100644
--- a/src/qml/Qt6QmlMacros.cmake
+++ b/src/qml/Qt6QmlMacros.cmake
@@ -2652,6 +2652,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}")
@@ -2701,31 +2737,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)