summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorLeander Beernaert <leander.beernaert@qt.io>2019-08-13 16:46:28 +0200
committerLeander Beernaert <leander.beernaert@qt.io>2019-08-14 11:44:58 +0000
commit723d5c5056976dd30cab8e619a6b7ca06f7405e8 (patch)
tree39e190250580be408c2c600c77201fadbce973f9 /cmake
parentb4bd6eaf927d576612b47db40647180123b73cb9 (diff)
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: <RCC> <qresource prefix="/qt-project.org/scenegraph"> <file>"shaders/24bittextmask.frag"</file> </qrsource> <RCC> After processing by pro2cmake and add_qt_resource() we generate <RCC> <qresource prefix="/qt-project.org/scenegraph"> <file alias="data/shaders/24bittextmask.frag"> ${CMAKE_CURRENT_SOURCE_DIR}/data/shaders/24bittextmask.frag" </file> </qrsource> <RCC> 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 <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuild.cmake8
1 files changed, 8 insertions, 0 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index babc874475..78991df720 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()