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