From c2aa05991d79df57f826606157056c658c6de797 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 17 Oct 2022 15:23:27 +0200 Subject: [PATCH] CMake: Fix qt_add_resources missing dependency regression Adding target dependencies instead of file dependencies to the qrc processing custom command broke regeneration of the qrc file when translation source files were touched, as well as caused flaky build failures. Originally, the target dependencies were added to work around an issue with the Xcode generator (a custom command needing a common target). Limit the usage of target dependencies 'approach' to the Xcode generator only. This fixes the regression for non-Xcode generators, but will still cause issues for iOS + Xcode. A proper fix for Xcode will need more research. Amends 5b0e765ab0dddba86662925cb44aeac748a286b7 in qttools Amends cfd5485d41b2bf519d5b3c5162726cce195782ac Pick-to: 6.4 6.4.1 Fixes: QTBUG-107687 Fixes: QTBUG-108113 Task-number: QTBUG-103470 Change-Id: Ibddd05726deba2103c9c3c85a3fefd6d55798020 Reviewed-by: Alexey Edelev --- src/corelib/Qt6CoreMacros.cmake | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index e192092871..ba800d22dd 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -1822,13 +1822,20 @@ function(_qt_internal_process_resource target resourceName) endif() get_source_file_property( target_dependency ${file} ${scope_args} _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.") + + # The target dependency code path does not take care of rebuilds when ${file} + # is touched. Limit its usage to the Xcode generator to avoid the Xcode common + # dependency issue. + # TODO: Figure out how to avoid the issue on Xcode, while also enabling proper + # dependency tracking when ${file} is touched. + if(target_dependency AND CMAKE_GENERATOR STREQUAL "Xcode") + 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}) + else() + list(APPEND resource_dependencies ${file}) endif() _qt_internal_expose_source_file_to_ide(${target} "${file}") endforeach()