From e3bff85339a0cae201cb0958982a943f91099d49 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Mon, 29 Jun 2026 17:17:30 +0100 Subject: [PATCH] Disable unity builds for targets with only one source file. --- modules/CMakeLists.txt | 6 ++++++ vendor/CMakeLists.txt | 1 + 2 files changed, 7 insertions(+) diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 1574e5d96..bfd3c6f6d 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -77,6 +77,12 @@ macro(build_module SRC MODULE_SRC) PREFIX "" SUFFIX "" ) + list(LENGTH MODULE_SRC MODULE_SRC_COUNT) + if(MODULE_SRC_COUNT LESS_EQUAL 1) + set_target_properties(${SO} PROPERTIES + UNITY_BUILD OFF + ) + endif() add_dependencies(${SO} ${PROGRAM_NAME}) if(HAVE_LOCALIZATION) add_dependencies(${SO} module_language) diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index 5a4e02863..28c9518c8 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -14,6 +14,7 @@ foreach(LIBRARY IN LISTS LIBRARIES) set_target_properties(${LIBRARY_TARGET} PROPERTIES FOLDER "VendoredLibraries" PREFIX "" + UNITY_BUILD OFF ) endif() endif()