From 723d5c5056976dd30cab8e619a6b7ca06f7405e8 Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Tue, 13 Aug 2019 16:46:28 +0200 Subject: [PATCH] Fix QRC Resource paths for qrc files in subdirectories When pro2cmake converts qrc files that are located in a subdirectory there is an error in the resource paths for qrc files generated with add_qt_resource(). For instance, consider the contents of data/scenegraph.qrc: "shaders/24bittextmask.frag" After processing by pro2cmake and add_qt_resource() we generate ${CMAKE_CURRENT_SOURCE_DIR}/data/shaders/24bittextmask.frag" The expected qrc path for the resource should be prefix/shaders/..., but in CMake it becomes prefix/data/shaders/... due to the BASE parameter. To fix it we check whether BASE is set and whether there are no other aliases present on the source file before setting an alias with the original file path. Change-Id: If0a68a5ffa787704b10b740e20f875c9029509b0 Reviewed-by: Alexandru Croitor --- cmake/QtBuild.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index babc8744753..78991df7202 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -2539,6 +2539,14 @@ function(add_qt_resource target resourceName) if (rcc_BASE) foreach(file IN LISTS rcc_FILES) set(resource_file "${rcc_BASE}/${file}") + qt_get_relative_resource_path_for_file(alias ${resource_file}) + # Handle case where resources were generated from a directory + # different than the one where the main .pro file resides. + # Unless otherwise specified, we should use the original file path + # as alias. + if (alias STREQUAL resource_file) + set_source_files_properties(${resource_file} PROPERTIES alias ${file}) + endif() file(TO_CMAKE_PATH ${resource_file} resource_file) list(APPEND resource_files ${resource_file}) endforeach()