aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/qml/Qt6QmlMacros.cmake41
1 files changed, 39 insertions, 2 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake
index 9af3d52a47..08b422960a 100644
--- a/src/qml/Qt6QmlMacros.cmake
+++ b/src/qml/Qt6QmlMacros.cmake
@@ -349,6 +349,7 @@ function(qt6_add_qml_module target)
)
endif()
endif()
+ set_property(GLOBAL APPEND PROPERTY _qt_all_qml_uris ${arg_URI})
set_property(GLOBAL APPEND PROPERTY _qt_all_qml_output_dirs ${arg_OUTPUT_DIRECTORY})
set_property(GLOBAL APPEND PROPERTY _qt_all_qml_targets ${target})
@@ -428,12 +429,12 @@ function(qt6_add_qml_module target)
QT_QML_MODULE_DEPENDENCIES "${dependency}"
)
else()
- string(SUBSTRING ${dependency} 0 ${slash_position} dep_module)
+ string(SUBSTRING ${dependency} 0 ${slash_position} dep_module_uri)
math(EXPR slash_position "${slash_position} + 1")
string(SUBSTRING ${dependency} ${slash_position} -1 dep_version)
if (dep_version MATCHES "^([0-9]+(\\.[0-9]+)?|auto)$")
set_property(TARGET ${target} APPEND PROPERTY
- QT_QML_MODULE_DEPENDENCIES "${dep_module} ${dep_version}"
+ QT_QML_MODULE_DEPENDENCIES "${dep_module_uri} ${dep_version}"
)
else()
message(FATAL_ERROR
@@ -443,6 +444,7 @@ function(qt6_add_qml_module target)
endif()
endif()
endforeach()
+ _qt_internal_collect_qml_module_dependencies(${target})
if(arg_AUTO_RESOURCE_PREFIX)
if(arg_RESOURCE_PREFIX)
@@ -4058,3 +4060,38 @@ function(_qt_internal_add_qml_static_plugin_dependency target dep_target)
"$<${skip_prl_marker}:$<TARGET_NAME:${dep_target}>>")
endif()
endfunction()
+
+function(_qt_internal_collect_qml_module_dependencies target)
+ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.19.0")
+ cmake_language(EVAL CODE
+ "cmake_language(DEFER CALL _qt_internal_collect_qml_module_dependencies_deferred \"${target}\")"
+ )
+ else()
+ _qt_internal_collect_qml_module_dependencies_deferred("${target}")
+ endif()
+endfunction()
+
+function(_qt_internal_collect_qml_module_dependencies_deferred target)
+ get_target_property(deps ${target} QT_QML_MODULE_DEPENDENCIES)
+ if(NOT deps)
+ return()
+ endif()
+ foreach(dep IN LISTS deps)
+ string(REPLACE " " ";" dep "${dep}")
+ list(GET dep 0 dep_module_uri)
+ get_property(qml_uris GLOBAL PROPERTY _qt_all_qml_uris)
+ list(FIND qml_uris "${dep_module_uri}" index)
+ if(index LESS 0)
+ continue()
+ endif()
+ get_property(qml_targets GLOBAL PROPERTY _qt_all_qml_targets)
+ list(GET qml_targets ${index} dep_module)
+ # Make the module target dependent on its non-imported QML dependencies.
+ if(TARGET "${dep_module}")
+ get_target_property(is_imported ${dep_module} IMPORTED)
+ if(NOT is_imported)
+ add_dependencies(${target} ${dep_module})
+ endif()
+ endif()
+ endforeach()
+endfunction()