From e925ebd39c458341913950848b618277848dda42 Mon Sep 17 00:00:00 2001 From: Jarkko Koivikko Date: Sat, 20 Feb 2021 11:40:25 +0200 Subject: CMake: Handle the case of QML resources in the BINARY directory Qt Virtual Keyboard copies some QML resources to the BINARY directory for dynamic configuration of resources. _qt_internal_quick_compiler_process_resources assumes that all QML source files are located under the SOURCE directory. This is perfectly fine as long as the SOURCE and BINARY directories are located on the same drive in Windows. Otherwise, the relative path cannot be resolved and cmake is aborted because a directory cannot be created below. Fix this problem by making sure that the relative path is resolved against the correct base directory. Change-Id: I93e31e9f2720d448a48b6e8075cee0c01f59b584 Reviewed-by: Ulf Hermann (cherry picked from commit 1bc4fb2e400c4c5865282a711d1a443ca0ab26fa) Reviewed-by: Qt Cherry-pick Bot --- src/qml/Qt6QmlMacros.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake index c86bcb1cb8..01ee8fc4d4 100644 --- a/src/qml/Qt6QmlMacros.cmake +++ b/src/qml/Qt6QmlMacros.cmake @@ -985,7 +985,12 @@ function(_qt_internal_quick_compiler_process_resources target resource_name) foreach(file IN LISTS qml_files) get_filename_component(file_absolute ${file} ABSOLUTE) - file(RELATIVE_PATH file_relative ${CMAKE_CURRENT_SOURCE_DIR} ${file_absolute}) + string(FIND "${file_absolute}" "${CMAKE_SOURCE_DIR}" start_index_of_source_dir) + if (start_index_of_source_dir EQUAL 0) + file(RELATIVE_PATH file_relative ${CMAKE_CURRENT_SOURCE_DIR} ${file_absolute}) + else() + file(RELATIVE_PATH file_relative ${CMAKE_CURRENT_BINARY_DIR} ${file_absolute}) + endif() __qt_get_relative_resource_path_for_file(file_resource_path ${file}) if (arg_PREFIX STREQUAL "/") # TO_CMAKE_PATH does not clean up cases such as //Foo -- cgit v1.2.3