diff options
author | Alexey Edelev <alexey.edelev@qt.io> | 2023-12-06 09:13:23 +0100 |
---|---|---|
committer | 🌴 Alexey Edelev 🌴 <alexey.edelev@qt.io> | 2023-12-19 14:49:32 +0000 |
commit | 8a238c0ab8a8c6ad3851315193c118e859b6da7a (patch) | |
tree | 05885f773a463ac5e7c5fbfef2a4802b64adfe10 /src/qml/Qt6QmlMacros.cmake | |
parent | 4d7ce35bd2b3a7319973303f163c26cdf67c73f6 (diff) |
Add the explicit CMake dependencies between QML module targets
If QML modules are built in the same build tree, and one depends on
another according to the DEPENDENCIES argument, we need to add the
explicit CMake depdencies between their targets. This is required since
the targets that use those QML modules not necessarly have explicit
dependencies on their QML DEPENDENCIES.
Pick-to: 6.5 6.6 6.7
Change-Id: Ibaf07c63a44b5e3a9f0b73136b5b0c00cd3352b3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src/qml/Qt6QmlMacros.cmake')
-rw-r--r-- | src/qml/Qt6QmlMacros.cmake | 41 |
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() |