meson: handle single header and multiheader the same way CMake does

This uses a meson option (set in `meson_options.txt`) to control whether
multi-header or single-header setup is wanted.
This commit is contained in:
Dylan Baker 2024-09-09 10:07:07 -07:00
parent a29af9c381
commit 16dca3c6dd
2 changed files with 14 additions and 7 deletions

View File

@ -6,19 +6,20 @@ project('nlohmann_json',
default_options: ['cpp_std=c++11'],
)
if get_option('MultipleHeaders')
incdir = 'include'
else
incdir = 'single_include'
endif
nlohmann_json_dep = declare_dependency(
include_directories: include_directories('single_include')
include_directories: include_directories(incdir)
)
meson.override_dependency('nlohmann_json', nlohmann_json_dep)
nlohmann_json_multiple_headers = declare_dependency(
include_directories: include_directories('include')
)
meson.override_dependency('nlohmann_json_multiple_headers', nlohmann_json_multiple_headers)
if not meson.is_subproject()
install_subdir(
'single_include/nlohmann',
incdir / 'nlohmann',
install_dir: get_option('includedir'),
install_tag: 'devel',
)

6
meson_options.txt Normal file
View File

@ -0,0 +1,6 @@
option(
'MultipleHeaders',
type: 'boolean',
value: true,
description: 'Use non-amalgomated version of the library',
)