1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-21 01:39:36 +01:00
nix/nix-meson-build-support/common/meson.build
Sergei Zimmerman c105846646
meson: Add option for controlling PCH
In practice it turns out that turning off PCH is pretty
useful when debugging incorrect includes. I didn't want
to add this option initially because of the sheer amount
of copy-pasta that meson requires. But considering that
this is useful and the cost of copying the option a single
time is not too high this seems acceptable.
2025-10-08 02:56:16 +03:00

50 lines
1.5 KiB
Meson

# This is only conditional to work around
# https://github.com/mesonbuild/meson/issues/13293. It should be
# unconditional.
if not (host_machine.system() == 'windows' and cxx.get_id() == 'gcc')
deps_private += dependency('threads')
endif
if host_machine.system() == 'cygwin'
# -std=gnu on cygwin defines 'unix', which conflicts with the namespace
add_project_arguments(
'-D_POSIX_C_SOURCE=200809L',
'-D_GNU_SOURCE',
language : 'cpp',
)
endif
add_project_arguments(
'-Wdeprecated-copy',
'-Werror=suggest-override',
'-Werror=switch',
'-Werror=switch-enum',
'-Werror=undef',
'-Werror=unused-result',
'-Werror=sign-compare',
'-Wignored-qualifiers',
'-Wimplicit-fallthrough',
'-Wno-deprecated-declarations',
language : 'cpp',
)
# GCC doesn't benefit much from precompiled headers.
if get_option('pch') == 'auto'
do_pch = cxx.get_id() == 'clang'
else
do_pch = get_option('pch') == 'enabled'
endif
# This is a clang-only option for improving build times.
# It forces the instantiation of templates in the PCH itself and
# not every translation unit it's included in.
# It's available starting from clang 11, which is old enough to not
# bother checking the version.
# This feature helps in particular with the expensive nlohmann::json template
# instantiations in libutil and libstore.
if cxx.get_id() == 'clang' and do_pch
add_project_arguments('-fpch-instantiate-templates', language : 'cpp')
endif
# Darwin ld doesn't like "X.Y.Zpre"
nix_soversion = meson.project_version().split('pre')[0]