summaryrefslogtreecommitdiffstats
path: root/src/corelib/Qt6CoreMacros.cmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2021-05-14 15:31:30 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2021-05-18 16:02:52 +0200
commit92185d417de43237ae62eae55599c65922cd9a15 (patch)
tree729e22c7932ed9556d959d57eb0c7ad9779fb450 /src/corelib/Qt6CoreMacros.cmake
parent18aad6da87a329ddf7ca7c92bf2371628220fb4f (diff)
Fix BASE argument of qt_add_resources
The BASE argument of qt_add_resources now denotes the root point of the alias of the file. Before, BASE was merely prepended to every file that got passed to qt_add_resources. Old behavior: qt_add_resources(app "images" PREFIX "/" BASE "../shared" FILES "images/button.png") Alias is "../shared/images/button.png", and pro2cmake generated QT_RESOURCE_ALIAS assignments to fix this. New behavior: qt_add_resources(app "images" PREFIX "/" BASE "../shared" FILES "../shared/images/button.png") The alias is "images/button.png". No extra QT_RESOURCE_ALIAS assignment is needed. The new behavior is in effect for user projects and for Qt repositories that define QT_USE_FIXED_QT_ADD_RESOURCE_BASE. Qt repositories will be ported one by one to this new behavior. Then the old code path can be removed. Pick-to: 6.1 Task-number: QTBUG-86726 Change-Id: Ib895edd4df8e97b54badadd9a1c34408beff131f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src/corelib/Qt6CoreMacros.cmake')
-rw-r--r--src/corelib/Qt6CoreMacros.cmake52
1 files changed, 36 insertions, 16 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index 6ebcf279ba..6e825c2a63 100644
--- a/src/corelib/Qt6CoreMacros.cmake
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -1425,23 +1425,43 @@ function(_qt_internal_process_resource target resourceName)
string(REPLACE "." "_" resourceName ${resourceName})
set(output_targets "")
- # Apply base to all files
- 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 QT_RESOURCE_ALIAS ${file})
- endif()
- file(TO_CMAKE_PATH ${resource_file} resource_file)
- list(APPEND resource_files ${resource_file})
- endforeach()
- else()
+ if(NOT DEFINED QT_REPO_MODULE_VERSION OR QT_USE_FIXED_QT_ADD_RESOURCE_BASE)
+ # Use the fixed BASE argument instead of the slightly broken one from 6.0.
set(resource_files ${rcc_FILES})
+ if(NOT "${rcc_BASE}" STREQUAL "")
+ get_filename_component(abs_base "${rcc_BASE}" ABSOLUTE)
+ foreach(file_path IN LISTS resource_files)
+ get_source_file_property(alias "${file_path}" QT_RESOURCE_ALIAS)
+ if(alias STREQUAL "NOTFOUND")
+ get_filename_component(abs_file "${file_path}" ABSOLUTE)
+ file(RELATIVE_PATH rel_file "${abs_base}" "${abs_file}")
+ set_property(SOURCE "${file_path}" PROPERTY QT_RESOURCE_ALIAS "${rel_file}")
+ endif()
+ endforeach()
+ endif()
+ else()
+ # TODO: Remove this else branch, once every Qt module defines
+ # QT_USE_FIXED_QT_ADD_RESOURCE_BASE.
+
+ # Apply base to all files
+ if (rcc_BASE)
+ foreach(file_path IN LISTS rcc_FILES)
+ set(resource_file "${rcc_BASE}/${file_path}")
+ __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
+ QT_RESOURCE_ALIAS ${file_path})
+ endif()
+ file(TO_CMAKE_PATH ${resource_file} resource_file)
+ list(APPEND resource_files ${resource_file})
+ endforeach()
+ else()
+ set(resource_files ${rcc_FILES})
+ endif()
endif()
if(NOT rcc_PREFIX)