diff options
author | Mike Achtelik <mike.achtelik@gmail.com> | 2021-09-30 20:54:16 +0200 |
---|---|---|
committer | Mike Achtelik <mike.achtelik@gmail.com> | 2021-10-12 17:36:57 +0000 |
commit | 91d8443f6d8169692b12b53f271b4f7add2fb46c (patch) | |
tree | 31ed33f45248eb2779c627be6eb1ddfc01f00841 /src/corelib/Qt6CoreMacros.cmake | |
parent | 8513bcd90cc3900f9c32e59e0823f621ea6eea1d (diff) |
CMake: Fix adding generated resources on iOS with CMake and Xcode
When adding resources generated via a custom command, the project fails
to configure when targeting iOS with CMake and Xcode with the error:
CMake Error in src/CMakeLists.txt:
The custom command generating
src/.qsb/TestShader.frag.qsb
is attached to multiple targets:
TestApp_other_files
TestApp
but none of these is a common dependency of the other(s). This is
not allowed by the Xcode "new build system".
This happens e.g. when using qt6_add_shaders, which adds a custom
command to generate the qsb files. Or by simply adding resources via
qt6_add_resources, which depend on a custom command.
The problem is that qt6_add_resources also adds the resource to a
second "fake" target ${target}_other_files via
_qt_internal_process_resource and _qt_internal_expose_source_file_to_ide.
See c7d1874cd16ce86dfbab319e44fe3a387378fdff.
Since these targets do not have a common dependency CMake fails to
configure the project.
So lets fix it similar to change 1bd0a5ce02352a600367beb5a5421c8f8332e1fe
and let the ${target}_other_files depend in the main ${target}.
Pick-to: 6.2
Task-number: QTBUG-95763
Change-Id: Iecdb40993a91da8bfbf6553892f9b0722d2e886c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src/corelib/Qt6CoreMacros.cmake')
-rw-r--r-- | src/corelib/Qt6CoreMacros.cmake | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index 223bdd6aac..4b93834ac5 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -1775,6 +1775,14 @@ function(_qt_internal_expose_source_file_to_ide target file) set(ide_target ${target}_other_files) if(NOT TARGET ${ide_target}) add_custom_target(${ide_target} SOURCES "${file}") + + # The new Xcode build system requires a common target to drive the generation of files, + # otherwise project configuration fails. + # By adding ${target} as a dependency of ${target}_other_files, + # it becomes the common target, so project configuration succeeds. + if(CMAKE_GENERATOR STREQUAL "Xcode") + add_dependencies(${ide_target} ${target}) + endif() else() set_property(TARGET ${ide_target} APPEND PROPERTY SOURCES "${file}") endif() |