summaryrefslogtreecommitdiffstats
path: root/cmake/QtResource.cmake.in
diff options
context:
space:
mode:
authorLeander Beernaert <leander.beernaert@qt.io>2019-10-15 14:01:48 +0200
committerLeander Beernaert <leander.beernaert@qt.io>2019-10-15 13:46:36 +0000
commitc13bafec0928b94e8e1ab8544efb6336bf4842c9 (patch)
tree8c415b3a6b51795595592c86284b6b3c88823a48 /cmake/QtResource.cmake.in
parent69bb9f7cadec8b03a18ba9a33075201988ae058e (diff)
Add QT_RESOURCE_TARGET_DEPENDENCY source file property
In the plugin test in QtBase we have a scenario where we have target binaries that are inputs to add_qt_resource(). If we do not remove these files from the dependency list for add_custom_command() cmake will fail to generate the build files. If we mark them as generated source files, we'd have to add a special rule to generate them. Furthermore, using $<TARGET_FILE:...> does not work due processing done by add_qt_resource. To bypass this we check whether the property is set and instead of adding the file to the dependency list we add the target referenced in that property. RCC will still work as expected but will fail if the files aren't present. Change-Id: I16855a54f5606d6fe27ab1347ed7ff4f40392c98 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'cmake/QtResource.cmake.in')
-rw-r--r--cmake/QtResource.cmake.in13
1 files changed, 12 insertions, 1 deletions
diff --git a/cmake/QtResource.cmake.in b/cmake/QtResource.cmake.in
index c1754fd883..335cbde33c 100644
--- a/cmake/QtResource.cmake.in
+++ b/cmake/QtResource.cmake.in
@@ -253,6 +253,7 @@ function(QT@PROJECT_VERSION_MAJOR@_PROCESS_RESOURCE target resourceName)
endif()
string(APPEND qrcContents ">\n")
+ set(resource_dependencies)
foreach(file IN LISTS resources)
__qt_get_relative_resource_path_for_file(file_resource_path ${file})
@@ -265,6 +266,16 @@ function(QT@PROJECT_VERSION_MAJOR@_PROCESS_RESOURCE target resourceName)
string(APPEND qrcContents " <file alias=\"${file_resource_path}\">")
string(APPEND qrcContents "${file}</file>\n")
list(APPEND files "${file}")
+
+ get_source_file_property(target_dependency ${file} QT_RESOURCE_TARGET_DEPENDENCY)
+ if (NOT target_dependency)
+ list(APPEND resource_dependencies ${file})
+ else()
+ if (NOT TARGET ${target_dependency})
+ message(FATAL_ERROR "Target dependency on resource file ${file} is not a cmake target.")
+ endif()
+ list(APPEND resource_dependencies ${target_dependency})
+ endif()
endforeach()
# </qresource></RCC>
@@ -282,7 +293,7 @@ function(QT@PROJECT_VERSION_MAJOR@_PROCESS_RESOURCE target resourceName)
add_custom_command(OUTPUT "${generatedSourceCode}"
COMMAND "@QT_CMAKE_EXPORT_NAMESPACE@::rcc"
ARGS ${rccArgs}
- DEPENDS ${resources} ${generatedResourceFile}
+ DEPENDS ${resource_dependencies} ${generatedResourceFile}
COMMENT "RCC ${newResourceName}"
VERBATIM)