Skip to content

Commit

Permalink
CMake: Disable unity builds project-wide
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dextercd committed Dec 22, 2024
1 parent f8c328e commit f5202af
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f5202af

Please sign in to comment.