summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2024-01-23 13:40:26 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-01-24 09:13:56 +0000
commit17c191365d1d1c0f02968ab4a5668384dd9c87ef (patch)
tree6a076148c53d7e978dde21f939cbe1a2bc8c7bdd /cmake
parent683dca1948f883d8f83c2839e6fae2960e1bfc77 (diff)
CMake: Fix unity build for qtgraphs
qtgraphs defines a target in one directory, and then calls qt_internal_extend_target with NO_UNITY_BUILD_SOURCES in another subdirectory scope. That in turn calls set_source_files_properties but only for the latter subdirectory, and not the main target directory. Because CMake has per-directory-scope source file properties, the 'no unity sources' option was effectively ignored. When using CMake 3.18, make sure to specify the TARGET_DIRECTORY option so that the source file properties are added to the scope of the defining target. Pick-to: 6.5 Change-Id: I4190d4073a2955aa7053b5faaaa57f683bc768a2 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 081e50d768114aeeb8f0d284989986d4debc6ec3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit dcaab5eb8d4b5d9388e295a25b8988e3094e83bd)
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtUnityBuildHelpers.cmake11
1 files changed, 9 insertions, 2 deletions
diff --git a/cmake/QtUnityBuildHelpers.cmake b/cmake/QtUnityBuildHelpers.cmake
index b66c6765ba..e804396f59 100644
--- a/cmake/QtUnityBuildHelpers.cmake
+++ b/cmake/QtUnityBuildHelpers.cmake
@@ -11,7 +11,14 @@ function(_qt_internal_validate_no_unity_build prefix)
endfunction()
function(qt_update_ignore_unity_build_sources target sources)
- if (sources)
- set_source_files_properties(${sources} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
+ if(sources)
+ # We need to add the TARGET_DIRECTORY scope for targets that have qt_internal_extend_target
+ # calls in different subdirectories, like in qtgraphs.
+ set(scope_args)
+ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
+ set(scope_args TARGET_DIRECTORY ${target})
+ endif()
+ set_source_files_properties(${sources} ${scope_args}
+ PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
endif()
endfunction()