diff options
author | Craig Scott <craig.scott@qt.io> | 2021-06-16 17:23:12 +1000 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-06-16 20:00:43 +0000 |
commit | 1ca34b06633c80f9baa9f7d852c181fc4ec96ab7 (patch) | |
tree | d0b67f2edbfe7271b2b0a0bb62ab0616614df8d5 | |
parent | d55d9e730bb13c76442f501c164e019eafdb9d58 (diff) |
Install .qml files from source dir and honor their resource alias
For targets that are built as part of Qt, we currently require all .qml
files to be passed to qt_internal_add_qml_module(). We can use that to
iterate over the set of qml files and access their source file
properties at configure time. The previous approach tried to use the
list obtained at generate time, but the source file properties (and
therefore their resource aliases) were not accessible and the install
locations assumed no resource path or alias.
By installing from the source dir, we also address the dependency issue
where an install wouldn't cause the build dir copies to be updated. The
install target will always install the latest source files with this
change.
Fixes: QTBUG-94519
Fixes: QTBUG-94520
Change-Id: I6a97a9631ff77c3f7696899a347b83c2eb4b0ca4
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit d8b3becc79a8d352d935c33084d29fc2bc088ea8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/qml/Qt6QmlBuildInternals.cmake | 22 | ||||
-rw-r--r-- | src/qml/Qt6QmlMacros.cmake | 11 |
2 files changed, 19 insertions, 14 deletions
diff --git a/src/qml/Qt6QmlBuildInternals.cmake b/src/qml/Qt6QmlBuildInternals.cmake index 2532d31cb9..6f44eceab1 100644 --- a/src/qml/Qt6QmlBuildInternals.cmake +++ b/src/qml/Qt6QmlBuildInternals.cmake @@ -271,11 +271,23 @@ function(qt_internal_add_qml_module target) ) endif() - # Empty list will not cause an installation error. - qt_install( - FILES $<TARGET_PROPERTY:${target},QT_QML_MODULE_FILES> - DESTINATION "${arg_INSTALL_DIRECTORY}" - ) + if(DEFINED arg_QML_FILES) + foreach(qml_file IN LISTS arg_QML_FILES) + __qt_get_relative_resource_path_for_file(file_resource_path ${qml_file}) + get_filename_component(resource_dir ${file_resource_path} DIRECTORY) + get_filename_component(resource_name ${file_resource_path} NAME) + if(resource_dir) + set(dest "${arg_INSTALL_DIRECTORY}/${resource_dir}") + else() + set(dest "${arg_INSTALL_DIRECTORY}") + endif() + qt_install( + FILES ${qml_file} + DESTINATION ${dest} + RENAME ${resource_name} + ) + endforeach() + endif() if(NOT arg_NO_GENERATE_QMLTYPES) qt_install( diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake index 66a47fcf87..b7cc657e68 100644 --- a/src/qml/Qt6QmlMacros.cmake +++ b/src/qml/Qt6QmlMacros.cmake @@ -1231,15 +1231,7 @@ function(qt6_target_qml_sources target) # build-time rule. This avoids having to re-run CMake just to re-copy # the file. get_filename_component(file_absolute ${qml_file_src} ABSOLUTE) - file(RELATIVE_PATH file_relative ${CMAKE_CURRENT_SOURCE_DIR} ${file_absolute}) - - get_property(alias SOURCE ${qml_file_src} PROPERTY QT_RESOURCE_ALIAS) - if(alias) - set(file_resource_path ${alias}) - else() - set(file_resource_path ${file_relative}) - endif() - + __qt_get_relative_resource_path_for_file(file_resource_path ${qml_file_src}) set(qml_file_out ${output_dir}/${file_resource_path}) # Don't generate or copy the file in an in-source build if the source @@ -1353,6 +1345,7 @@ function(qt6_target_qml_sources target) QT_QML_MODULE_RESOURCE_PATHS ${file_resource_path} ) + file(RELATIVE_PATH file_relative ${CMAKE_CURRENT_SOURCE_DIR} ${file_absolute}) string(REGEX REPLACE "\\.(js|mjs|qml)$" "_\\1" compiled_file ${file_relative}) string(REGEX REPLACE "[$#?]+" "_" compiled_file ${compiled_file}) set(compiled_file "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache/${target}/${compiled_file}.cpp") |