blob: 8de947c4cdf80ea8ef77125e3fe2e279603d8e4c [file] [log] [blame]
David Seiferted258de2017-06-26 06:11:51 +02001project(
2 'jsoncpp',
3 'cpp',
Frank Richter69402d12019-03-23 21:03:30 +01004 version : '1.9.0',
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',
Jordan Bayles185dfd52019-06-24 13:38:00 -070010 meson_version : '>= 0.50.0')
David Seiferted258de2017-06-26 06:11:51 +020011
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
Peter Spiess-Knaflb87f6db2018-06-18 11:28:56 +020049if get_option('default_library') == 'shared' and meson.get_compiler('cpp').get_id() == 'msvc'
50 dll_export_flag = '-DJSON_DLL_BUILD'
51 dll_import_flag = '-DJSON_DLL'
52else
Christopher Dunn59d41de2018-06-23 17:34:40 -050053 dll_export_flag = []
54 dll_import_flag = []
Peter Spiess-Knaflb87f6db2018-06-18 11:28:56 +020055endif
56
David Seiferted258de2017-06-26 06:11:51 +020057jsoncpp_lib = library(
58 'jsoncpp',
59 [ jsoncpp_gen_sources,
60 jsoncpp_headers,
61 'src/lib_json/json_tool.h',
62 'src/lib_json/json_reader.cpp',
63 'src/lib_json/json_value.cpp',
64 'src/lib_json/json_writer.cpp'],
Frank Richter69402d12019-03-23 21:03:30 +010065 soversion : 21,
David Seiferted258de2017-06-26 06:11:51 +020066 install : true,
Peter Spiess-Knaflb87f6db2018-06-18 11:28:56 +020067 include_directories : jsoncpp_include_directories,
68 cpp_args: dll_export_flag)
David Seiferted258de2017-06-26 06:11:51 +020069
70import('pkgconfig').generate(
71 libraries : jsoncpp_lib,
72 version : meson.project_version(),
73 name : 'jsoncpp',
74 filebase : 'jsoncpp',
75 description : 'A C++ library for interacting with JSON')
76
77# for libraries bundling jsoncpp
Jason S Zang43fd41d2017-09-16 11:19:30 +010078jsoncpp_dep = declare_dependency(
David Seiferted258de2017-06-26 06:11:51 +020079 include_directories : jsoncpp_include_directories,
80 link_with : jsoncpp_lib,
81 version : meson.project_version(),
82 sources : jsoncpp_gen_sources)
83
84# tests
85python = import('python3').find_python()
86
87jsoncpp_test = executable(
88 'jsoncpp_test',
89 [ 'src/test_lib_json/jsontest.cpp',
90 'src/test_lib_json/jsontest.h',
Google AutoFuzz Team879a5b82019-06-26 17:40:59 -040091 'src/test_lib_json/main.cpp',
92 'src/test_lib_json/fuzz.cpp'],
David Seiferted258de2017-06-26 06:11:51 +020093 include_directories : jsoncpp_include_directories,
94 link_with : jsoncpp_lib,
Peter Spiess-Knaflb87f6db2018-06-18 11:28:56 +020095 install : false,
96 cpp_args: dll_import_flag)
David Seiferted258de2017-06-26 06:11:51 +020097test(
98 'unittest_jsoncpp_test',
99 jsoncpp_test)
100
101jsontestrunner = executable(
102 'jsontestrunner',
103 'src/jsontestrunner/main.cpp',
104 include_directories : jsoncpp_include_directories,
105 link_with : jsoncpp_lib,
Peter Spiess-Knaflb87f6db2018-06-18 11:28:56 +0200106 install : false,
107 cpp_args: dll_import_flag)
David Seiferted258de2017-06-26 06:11:51 +0200108test(
109 'unittest_jsontestrunner',
110 python,
111 args : [
112 '-B',
113 join_paths(meson.current_source_dir(), 'test/runjsontests.py'),
114 jsontestrunner,
115 join_paths(meson.current_source_dir(), 'test/data')]
116 )