From 50b8d61030e08a71f61d172d7d830d1eaae92bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dexter=20Castor=20D=C3=B6pping?= Date: Sun, 22 Dec 2024 13:44:03 +0100 Subject: [PATCH] CMake: Disable unity builds project-wide liblzma and xz can't be compiled as a unity/jumbo build because of redeclarations and type name reuse. The CMake documentation recommends setting UNITY_BUILD to false in this case. This is especially important if we're compiled as a subproject and the consumer wants to use CMAKE_UNITY_BUILD=ON for the rest of their code base. Closes: https://github.com/tukaani-project/xz/pull/158 (cherry picked from commit bf6da9a573a780cd1a7fb1728ef55d09e58dad11) --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 664c881a..e0863573 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,6 +175,12 @@ endif() # On Apple OSes, don't build executables as bundles: set(CMAKE_MACOSX_BUNDLE OFF) +# The targets defined here don't support compiling as a unity build. Encoder +# and decoder source files define different types with the same name, and some +# internal header files don't have header guards leading to redeclaration +# errors. +set(CMAKE_UNITY_BUILD OFF) + # Set CMAKE_INSTALL_LIBDIR and friends. This needs to be done before # the LOCALEDIR_DEFINITION workaround below. include(GNUInstallDirs)