blob: f68db30dd3f1e646039474c601c02fcc0bb634b4 [file] [log] [blame]
Haibo Huangb0bee822021-02-24 15:40:15 -08001project(
2 'jsoncpp',
3 'cpp',
4
5 # Note: version must be updated in three places when doing a release. This
6 # annoying process ensures that amalgamate, CMake, and meson all report the
7 # correct version.
8 # 1. /meson.build
9 # 2. /include/json/version.h
10 # 3. /CMakeLists.txt
11 # IMPORTANT: also update the SOVERSION!!
12 version : '1.9.4',
13 default_options : [
14 'buildtype=release',
15 'cpp_std=c++11',
16 'warning_level=1'],
17 license : 'Public Domain',
18 meson_version : '>= 0.49.0')
19
20
21jsoncpp_headers = files([
22 'include/json/allocator.h',
23 'include/json/assertions.h',
24 'include/json/config.h',
25 'include/json/json_features.h',
26 'include/json/forwards.h',
27 'include/json/json.h',
28 'include/json/reader.h',
29 'include/json/value.h',
30 'include/json/version.h',
31 'include/json/writer.h',
32])
33jsoncpp_include_directories = include_directories('include')
34
35install_headers(
36 jsoncpp_headers,
37 subdir : 'json')
38
39if get_option('default_library') == 'shared' and meson.get_compiler('cpp').get_id() == 'msvc'
40 dll_export_flag = '-DJSON_DLL_BUILD'
41 dll_import_flag = '-DJSON_DLL'
42else
43 dll_export_flag = []
44 dll_import_flag = []
45endif
46
47jsoncpp_lib = library(
48 'jsoncpp', files([
49 'src/lib_json/json_reader.cpp',
50 'src/lib_json/json_value.cpp',
51 'src/lib_json/json_writer.cpp',
52 ]),
Elliott Hughes1601ea02021-12-07 09:43:38 -080053 soversion : 25,
Haibo Huangb0bee822021-02-24 15:40:15 -080054 install : true,
55 include_directories : jsoncpp_include_directories,
56 cpp_args: dll_export_flag)
57
58import('pkgconfig').generate(
59 libraries : jsoncpp_lib,
60 version : meson.project_version(),
61 name : 'jsoncpp',
62 filebase : 'jsoncpp',
63 description : 'A C++ library for interacting with JSON')
64
65# for libraries bundling jsoncpp
66jsoncpp_dep = declare_dependency(
67 include_directories : jsoncpp_include_directories,
68 link_with : jsoncpp_lib,
69 version : meson.project_version())
70
71# tests
72if meson.is_subproject() or not get_option('tests')
73 subdir_done()
74endif
75
76python = import('python').find_installation()
77
78jsoncpp_test = executable(
79 'jsoncpp_test', files([
80 'src/test_lib_json/jsontest.cpp',
81 'src/test_lib_json/main.cpp',
82 'src/test_lib_json/fuzz.cpp',
83 ]),
84 include_directories : jsoncpp_include_directories,
85 link_with : jsoncpp_lib,
86 install : false,
87 cpp_args: dll_import_flag)
88test(
89 'unittest_jsoncpp_test',
90 jsoncpp_test)
91
92jsontestrunner = executable(
93 'jsontestrunner',
94 'src/jsontestrunner/main.cpp',
95 include_directories : jsoncpp_include_directories,
96 link_with : jsoncpp_lib,
97 install : false,
98 cpp_args: dll_import_flag)
99test(
100 'unittest_jsontestrunner',
101 python,
102 args : [
103 '-B',
104 join_paths(meson.current_source_dir(), 'test/runjsontests.py'),
105 jsontestrunner,
106 join_paths(meson.current_source_dir(), 'test/data')],
107 )
108test(
109 'jsonchecker_jsontestrunner',
110 python,
111 is_parallel : false,
112 args : [
113 '-B',
114 join_paths(meson.current_source_dir(), 'test/runjsontests.py'),
115 '--with-json-checker',
116 jsontestrunner,
117 join_paths(meson.current_source_dir(), 'test/data')],
118 workdir : join_paths(meson.current_source_dir(), 'test/data'),
119 )