blob: f193fec5e6ed6c1dba480567a4f8bf7203ad814a [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)
Martin Dagarin49da91c2017-09-04 21:10:15 +020021jsoncpp_cdata.set('JSONCPP_USE_SECURE_MEMORY',0)
David Seiferted258de2017-06-26 06:11:51 +020022
23jsoncpp_gen_sources = configure_file(
24 input : 'src/lib_json/version.h.in',
25 output : 'version.h',
26 configuration : jsoncpp_cdata,
27 install : true,
28 install_dir : join_paths(get_option('prefix'), get_option('includedir'), 'json')
29)
30
31jsoncpp_headers = [
32 'include/json/allocator.h',
33 'include/json/assertions.h',
34 'include/json/autolink.h',
35 'include/json/config.h',
36 'include/json/features.h',
37 'include/json/forwards.h',
38 'include/json/json.h',
39 'include/json/reader.h',
40 'include/json/value.h',
41 'include/json/writer.h']
42jsoncpp_include_directories = include_directories('include')
43
44install_headers(
45 jsoncpp_headers,
46 subdir : 'json')
47
48jsoncpp_lib = library(
49 'jsoncpp',
50 [ jsoncpp_gen_sources,
51 jsoncpp_headers,
52 'src/lib_json/json_tool.h',
53 'src/lib_json/json_reader.cpp',
54 'src/lib_json/json_value.cpp',
55 'src/lib_json/json_writer.cpp'],
Christopher Dunnc98e1d82017-08-28 08:45:17 -050056 soversion : 19,
David Seiferted258de2017-06-26 06:11:51 +020057 install : true,
58 include_directories : jsoncpp_include_directories)
59
60import('pkgconfig').generate(
61 libraries : jsoncpp_lib,
62 version : meson.project_version(),
63 name : 'jsoncpp',
64 filebase : 'jsoncpp',
65 description : 'A C++ library for interacting with JSON')
66
67# for libraries bundling jsoncpp
68declare_dependency(
69 include_directories : jsoncpp_include_directories,
70 link_with : jsoncpp_lib,
71 version : meson.project_version(),
72 sources : jsoncpp_gen_sources)
73
74# tests
75python = import('python3').find_python()
76
77jsoncpp_test = executable(
78 'jsoncpp_test',
79 [ 'src/test_lib_json/jsontest.cpp',
80 'src/test_lib_json/jsontest.h',
81 'src/test_lib_json/main.cpp'],
82 include_directories : jsoncpp_include_directories,
83 link_with : jsoncpp_lib,
84 install : false)
85test(
86 'unittest_jsoncpp_test',
87 jsoncpp_test)
88
89jsontestrunner = executable(
90 'jsontestrunner',
91 'src/jsontestrunner/main.cpp',
92 include_directories : jsoncpp_include_directories,
93 link_with : jsoncpp_lib,
94 install : false)
95test(
96 'unittest_jsontestrunner',
97 python,
98 args : [
99 '-B',
100 join_paths(meson.current_source_dir(), 'test/runjsontests.py'),
101 jsontestrunner,
102 join_paths(meson.current_source_dir(), 'test/data')]
103 )