diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2022-06-14 17:28:54 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-06-17 18:59:32 +0000 |
commit | c9a79666ac72786c533ea906edb66320ed599772 (patch) | |
tree | 445cd2fa527a4cbee1d5e26e5c5e1c700ebf4ebb /src/corelib | |
parent | ba2584126b2047011e29ba0ea98bc55bd504ea62 (diff) |
CMake: Fix Xcode common dependency issues for other_files IDE target
A generated file can be added to a resource target, which in turn
adds it to the other_files target. With the Xcode generator, this can
lead to errors like
The custom command generating foo.txt is attached to multiple
targets:
foo_other_files
foo_resources_1
but none of these is a common dependency of the other(s). This is
not allowed by the Xcode "new build system".
Neither of the targets depend on each other because logically
they shouldn't depend on each other.
And yet XCode wants that each generated file is attached only to one
target, which will be a common dependency for the other targets.
Make sure _qt_internal_expose_source_file_to_ide extracts and uses
that common target dependency just like
qt_add_resources -> _qt_internal_process_resource already does.
One case of a common target dependency is the _lrelease target
in qttools which was added in 5b0e765ab0dddba86662925cb44aeac748a286b7
Another case is in qt_add_shaders in qtshadertools.
I expect we might encounter other cases where we need to introduce a
common driving target.
Task-number: QTBUG-103723
Change-Id: Ideff023718a6ce109a4b3eefa01bffa79d1c6a3e
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 20dd4a43f08c5417c1b7751b66e8b3fa337ad01d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/Qt6CoreMacros.cmake | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index 64213062a2..620d893abd 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -2020,6 +2020,19 @@ function(_qt_internal_expose_source_file_to_ide target file) else() set_property(TARGET ${ide_target} APPEND PROPERTY SOURCES "${file}") endif() + + set(scope_args) + if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18") + set(scope_args TARGET_DIRECTORY "${target}") + endif() + get_source_file_property( + target_dependency "${file}" ${scope_args} _qt_resource_target_dependency) + if(target_dependency) + if(NOT TARGET "${target_dependency}") + message(FATAL_ERROR "Target dependency on source file ${file} is not a cmake target.") + endif() + add_dependencies(${ide_target} ${target_dependency}) + endif() endfunction() # |