blob: a338cc0dd41e78aee966910b5702f14880abbf30 [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
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'],
Christopher Dunnddabf502017-12-20 14:52:26 -060065 soversion : 20,
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',
91 'src/test_lib_json/main.cpp'],
92 include_directories : jsoncpp_include_directories,
93 link_with : jsoncpp_lib,
Peter Spiess-Knaflb87f6db2018-06-18 11:28:56 +020094 install : false,
95 cpp_args: dll_import_flag)
David Seiferted258de2017-06-26 06:11:51 +020096test(
97 'unittest_jsoncpp_test',
98 jsoncpp_test)
99
100jsontestrunner = executable(
101 'jsontestrunner',
102 'src/jsontestrunner/main.cpp',
103 include_directories : jsoncpp_include_directories,
104 link_with : jsoncpp_lib,
Peter Spiess-Knaflb87f6db2018-06-18 11:28:56 +0200105 install : false,
106 cpp_args: dll_import_flag)
David Seiferted258de2017-06-26 06:11:51 +0200107test(
108 'unittest_jsontestrunner',
109 python,
110 args : [
111 '-B',
112 join_paths(meson.current_source_dir(), 'test/runjsontests.py'),
113 jsontestrunner,
114 join_paths(meson.current_source_dir(), 'test/data')]
115 )