From 16dca3c6dddcaf64c6a4de27466714bac1d23dfd Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 9 Sep 2024 10:07:07 -0700 Subject: [PATCH] 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. --- meson.build | 15 ++++++++------- meson_options.txt | 6 ++++++ 2 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 meson_options.txt diff --git a/meson.build b/meson.build index aff769eb2..5b82945d5 100644 --- a/meson.build +++ b/meson.build @@ -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', ) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 000000000..8291c1ac4 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,6 @@ +option( + 'MultipleHeaders', + type: 'boolean', + value: true, + description: 'Use non-amalgomated version of the library', +)