From eab5ec5a376eb6bb337ea71d76cbeeff5a5d7acf Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Thu, 10 Feb 2022 12:58:41 +0100 Subject: [PATCH] Strip the ending slashes for resource folders Setting a value for the QT_RESOURCE_ALIAS source file property on a path ending with a slash (a directory) is not handled properly by CMake. This leads to unpredictable values being set for multiple directories. Fix this by stripping the the final slash from the file path, which makes CMake think it's a file rather than a directory. Change-Id: I7a39be68e6f58bf2726c80108da9947057e7add6 Reviewed-by: Alexandru Croitor --- src/corelib/Qt6CoreMacros.cmake | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index 7ed5e2b1a66..6c809e10819 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -1775,7 +1775,18 @@ function(_qt_internal_process_resource target resourceName) string(REPLACE "/" "_" resourceName ${resourceName}) string(REPLACE "." "_" resourceName ${resourceName}) - set(resource_files ${rcc_FILES}) + set(resource_files "") + # Strip the ending slashes from the file_path. If paths contain slashes in the end + # set/get source properties works incorrect and may have the same QT_RESOURCE_ALIAS + # for two different paths. See https://gitlab.kitware.com/cmake/cmake/-/issues/23212 + # for details. + foreach(file_path IN LISTS rcc_FILES) + if(file_path MATCHES "(.+)/$") + set(file_path "${CMAKE_MATCH_1}") + endif() + list(APPEND resource_files ${file_path}) + endforeach() + if(NOT "${rcc_BASE}" STREQUAL "") get_filename_component(abs_base "${rcc_BASE}" ABSOLUTE) foreach(file_path IN LISTS resource_files)