blob: f2a6800f8df573abfdf93abffcf158537e827c4e [file] [log] [blame]
David Seiferted258de2017-06-26 06:11:51 +02001project(
2 'jsoncpp',
3 'cpp',
Christopher Dunnc98e1d82017-08-28 08:45:17 -05004 version : '1.8.3',
David Seiferted258de2017-06-26 06:11:51 +02005 default_options : [
6 'buildtype=release',
7 'warning_level=1'],
8 license : 'Public Domain',
9 meson_version : '>= 0.41.1')
10
11jsoncpp_ver_arr = meson.project_version().split('.')
12jsoncpp_major_version = jsoncpp_ver_arr[0]
13jsoncpp_minor_version = jsoncpp_ver_arr[1]
14jsoncpp_patch_version = jsoncpp_ver_arr[2]
15
16jsoncpp_cdata = configuration_data()
17jsoncpp_cdata.set('JSONCPP_VERSION', meson.project_version())
18jsoncpp_cdata.set('JSONCPP_VERSION_MAJOR', jsoncpp_major_version)
19jsoncpp_cdata.set('JSONCPP_VERSION_MINOR', jsoncpp_minor_version)
20jsoncpp_cdata.set('JSONCPP_VERSION_PATCH', jsoncpp_patch_version)
21
22jsoncpp_gen_sources = configure_file(
23 input : 'src/lib_json/version.h.in',
24 output : 'version.h',
25 configuration : jsoncpp_cdata,
26 install : true,
27 install_dir : join_paths(get_option('prefix'), get_option('includedir'), 'json')
28)
29
30jsoncpp_headers = [
31 'include/json/allocator.h',
32 'include/json/assertions.h',
33 'include/json/autolink.h',
34 'include/json/config.h',
35 'include/json/features.h',
36 'include/json/forwards.h',
37 'include/json/json.h',
38 'include/json/reader.h',
39 'include/json/value.h',
40 'include/json/writer.h']
41jsoncpp_include_directories = include_directories('include')
42
43install_headers(
44 jsoncpp_headers,
45 subdir : 'json')
46
47jsoncpp_lib = library(
48 'jsoncpp',
49 [ jsoncpp_gen_sources,
50 jsoncpp_headers,
51 'src/lib_json/json_tool.h',
52 'src/lib_json/json_reader.cpp',
53 'src/lib_json/json_value.cpp',
54 'src/lib_json/json_writer.cpp'],
Christopher Dunnc98e1d82017-08-28 08:45:17 -050055 soversion : 19,
David Seiferted258de2017-06-26 06:11:51 +020056 install : true,
57 include_directories : jsoncpp_include_directories)
58
59import('pkgconfig').generate(
60 libraries : jsoncpp_lib,
61 version : meson.project_version(),
62 name : 'jsoncpp',
63 filebase : 'jsoncpp',
64 description : 'A C++ library for interacting with JSON')
65
66# for libraries bundling jsoncpp
67declare_dependency(
68 include_directories : jsoncpp_include_directories,
69 link_with : jsoncpp_lib,
70 version : meson.project_version(),
71 sources : jsoncpp_gen_sources)
72
73# tests
74python = import('python3').find_python()
75
76jsoncpp_test = executable(
77 'jsoncpp_test',
78 [ 'src/test_lib_json/jsontest.cpp',
79 'src/test_lib_json/jsontest.h',
80 'src/test_lib_json/main.cpp'],
81 include_directories : jsoncpp_include_directories,
82 link_with : jsoncpp_lib,
83 install : false)
84test(
85 'unittest_jsoncpp_test',
86 jsoncpp_test)
87
88jsontestrunner = executable(
89 'jsontestrunner',
90 'src/jsontestrunner/main.cpp',
91 include_directories : jsoncpp_include_directories,
92 link_with : jsoncpp_lib,
93 install : false)
94test(
95 'unittest_jsontestrunner',
96 python,
97 args : [
98 '-B',
99 join_paths(meson.current_source_dir(), 'test/runjsontests.py'),
100 jsontestrunner,
101 join_paths(meson.current_source_dir(), 'test/data')]
102 )