David Seifert | ed258de | 2017-06-26 06:11:51 +0200 | [diff] [blame] | 1 | project( |
| 2 | 'jsoncpp', |
| 3 | 'cpp', |
Christopher Dunn | ddabf50 | 2017-12-20 14:52:26 -0600 | [diff] [blame] | 4 | version : '1.8.4', |
David Seifert | ed258de | 2017-06-26 06:11:51 +0200 | [diff] [blame] | 5 | default_options : [ |
| 6 | 'buildtype=release', |
Christopher Dunn | 899894f | 2017-12-21 01:22:40 -0600 | [diff] [blame] | 7 | 'cpp_std=c++11', |
David Seifert | ed258de | 2017-06-26 06:11:51 +0200 | [diff] [blame] | 8 | 'warning_level=1'], |
| 9 | license : 'Public Domain', |
| 10 | meson_version : '>= 0.41.1') |
| 11 | |
| 12 | jsoncpp_ver_arr = meson.project_version().split('.') |
| 13 | jsoncpp_major_version = jsoncpp_ver_arr[0] |
| 14 | jsoncpp_minor_version = jsoncpp_ver_arr[1] |
| 15 | jsoncpp_patch_version = jsoncpp_ver_arr[2] |
| 16 | |
| 17 | jsoncpp_cdata = configuration_data() |
| 18 | jsoncpp_cdata.set('JSONCPP_VERSION', meson.project_version()) |
| 19 | jsoncpp_cdata.set('JSONCPP_VERSION_MAJOR', jsoncpp_major_version) |
| 20 | jsoncpp_cdata.set('JSONCPP_VERSION_MINOR', jsoncpp_minor_version) |
| 21 | jsoncpp_cdata.set('JSONCPP_VERSION_PATCH', jsoncpp_patch_version) |
Martin Dagarin | 49da91c | 2017-09-04 21:10:15 +0200 | [diff] [blame] | 22 | jsoncpp_cdata.set('JSONCPP_USE_SECURE_MEMORY',0) |
David Seifert | ed258de | 2017-06-26 06:11:51 +0200 | [diff] [blame] | 23 | |
| 24 | jsoncpp_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 | |
| 32 | jsoncpp_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'] |
| 43 | jsoncpp_include_directories = include_directories('include') |
| 44 | |
| 45 | install_headers( |
| 46 | jsoncpp_headers, |
| 47 | subdir : 'json') |
| 48 | |
Peter Spiess-Knafl | b87f6db | 2018-06-18 11:28:56 +0200 | [diff] [blame^] | 49 | if 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' |
| 52 | else |
| 53 | dll_export_flag = '' |
| 54 | dll_import_flag = '' |
| 55 | endif |
| 56 | |
David Seifert | ed258de | 2017-06-26 06:11:51 +0200 | [diff] [blame] | 57 | jsoncpp_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 Dunn | ddabf50 | 2017-12-20 14:52:26 -0600 | [diff] [blame] | 65 | soversion : 20, |
David Seifert | ed258de | 2017-06-26 06:11:51 +0200 | [diff] [blame] | 66 | install : true, |
Peter Spiess-Knafl | b87f6db | 2018-06-18 11:28:56 +0200 | [diff] [blame^] | 67 | include_directories : jsoncpp_include_directories, |
| 68 | cpp_args: dll_export_flag) |
David Seifert | ed258de | 2017-06-26 06:11:51 +0200 | [diff] [blame] | 69 | |
| 70 | import('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 Zang | 43fd41d | 2017-09-16 11:19:30 +0100 | [diff] [blame] | 78 | jsoncpp_dep = declare_dependency( |
David Seifert | ed258de | 2017-06-26 06:11:51 +0200 | [diff] [blame] | 79 | include_directories : jsoncpp_include_directories, |
| 80 | link_with : jsoncpp_lib, |
| 81 | version : meson.project_version(), |
| 82 | sources : jsoncpp_gen_sources) |
| 83 | |
| 84 | # tests |
| 85 | python = import('python3').find_python() |
| 86 | |
| 87 | jsoncpp_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-Knafl | b87f6db | 2018-06-18 11:28:56 +0200 | [diff] [blame^] | 94 | install : false, |
| 95 | cpp_args: dll_import_flag) |
David Seifert | ed258de | 2017-06-26 06:11:51 +0200 | [diff] [blame] | 96 | test( |
| 97 | 'unittest_jsoncpp_test', |
| 98 | jsoncpp_test) |
| 99 | |
| 100 | jsontestrunner = executable( |
| 101 | 'jsontestrunner', |
| 102 | 'src/jsontestrunner/main.cpp', |
| 103 | include_directories : jsoncpp_include_directories, |
| 104 | link_with : jsoncpp_lib, |
Peter Spiess-Knafl | b87f6db | 2018-06-18 11:28:56 +0200 | [diff] [blame^] | 105 | install : false, |
| 106 | cpp_args: dll_import_flag) |
David Seifert | ed258de | 2017-06-26 06:11:51 +0200 | [diff] [blame] | 107 | test( |
| 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 | ) |