]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
CMake: Disable unity builds project-wide
authorDexter Castor Döpping <dexter.c.dopping@gmail.com>
Sun, 22 Dec 2024 12:44:03 +0000 (13:44 +0100)
committerLasse Collin <lasse.collin@tukaani.org>
Sun, 22 Dec 2024 18:06:24 +0000 (20:06 +0200)
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
CMakeLists.txt

index f800396d6875456696d9935bc13928354dda5532..fab4fb7141b87780aca5aad5a75dcc6e1fbb6706 100644 (file)
@@ -161,6 +161,12 @@ set(CMAKE_C_STANDARD 11)
 # 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)