Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring Meson build definition more in line with CMake #4452

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ endif()
option(JSON_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ${JSON_BuildTests_INIT})
option(JSON_CI "Enable CI build targets." OFF)
option(JSON_Diagnostics "Use extended diagnostic messages." OFF)
option(JSON_GlobalUDLs "Place use-defined string literals in the global namespace." ON)
option(JSON_GlobalUDLs "Place user-defined string literals in the global namespace." ON)
option(JSON_ImplicitConversions "Enable implicit conversions." ON)
option(JSON_DisableEnumSerialization "Disable default integer enum serialization." OFF)
option(JSON_LegacyDiscardedValueComparison "Enable legacy discarded value comparison." OFF)
Expand Down
40 changes: 28 additions & 12 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,39 @@ project('nlohmann_json',
'cpp',
version : '3.11.3',
license : 'MIT',
meson_version : '>= 0.64',
default_options: ['cpp_std=c++11'],
)

nlohmann_json_dep = declare_dependency(
include_directories: include_directories('single_include')
)
if get_option('MultipleHeaders')
incdir = 'include'
else
incdir = 'single_include'
endif

nlohmann_json_multiple_headers = declare_dependency(
include_directories: include_directories('include')
cpp_args = [
'-DJSON_USE_GLOBAL_UDLS=@0@'.format(
(not get_option('GlobalUDLs')).to_int()),
'-DJSON_USE_IMPLICIT_CONVERSIONS=@0@'.format(
(not get_option('ImplicitConversions')).to_int()),
]

nlohmann_json_dep = declare_dependency(
compile_args: cpp_args,
include_directories: include_directories(incdir)
)
meson.override_dependency('nlohmann_json', nlohmann_json_dep)

if not meson.is_subproject()
install_headers('single_include/nlohmann/json.hpp', subdir: 'nlohmann')
install_headers('single_include/nlohmann/json_fwd.hpp', subdir: 'nlohmann')
install_subdir(
incdir / 'nlohmann',
install_dir: get_option('includedir'),
install_tag: 'devel',
)

pkgc = import('pkgconfig')
pkgc.generate(name: 'nlohmann_json',
version: meson.project_version(),
description: 'JSON for Modern C++'
)
pkgc = import('pkgconfig')
pkgc.generate(name: 'nlohmann_json',
version: meson.project_version(),
description: 'JSON for Modern C++'
)
endif
18 changes: 18 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
option(
'MultipleHeaders',
type: 'boolean',
value: true,
description: 'Use non-amalgomated version of the library',
)
option(
'GlobalUDLs',
type: 'boolean',
value: true,
description: 'Place user-defined string literals in the global namespace',
)
option(
'ImplicitConversions',
type: 'boolean',
value: true,
description: 'Enable implicit conversions',
)