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 bf6da9a573)
This commit is contained in:
Dexter Castor Döpping 2024-12-22 13:44:03 +01:00 committed by Lasse Collin
parent 8a7d922fb8
commit 50b8d61030
No known key found for this signature in database
GPG Key ID: 38EE757D69184620
1 changed files with 6 additions and 0 deletions

View File

@ -175,6 +175,12 @@ endif()
# On Apple OSes, don't build executables as bundles: # On Apple OSes, don't build executables as bundles:
set(CMAKE_MACOSX_BUNDLE OFF) 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 # Set CMAKE_INSTALL_LIBDIR and friends. This needs to be done before
# the LOCALEDIR_DEFINITION workaround below. # the LOCALEDIR_DEFINITION workaround below.
include(GNUInstallDirs) include(GNUInstallDirs)