Haibo Huang | b0bee82 | 2021-02-24 15:40:15 -0800 | [diff] [blame] | 1 | project( |
| 2 | 'jsoncpp', |
| 3 | 'cpp', |
| 4 | |
| 5 | # Note: version must be updated in three places when doing a release. This |
| 6 | # annoying process ensures that amalgamate, CMake, and meson all report the |
| 7 | # correct version. |
| 8 | # 1. /meson.build |
| 9 | # 2. /include/json/version.h |
| 10 | # 3. /CMakeLists.txt |
| 11 | # IMPORTANT: also update the SOVERSION!! |
| 12 | version : '1.9.4', |
| 13 | default_options : [ |
| 14 | 'buildtype=release', |
| 15 | 'cpp_std=c++11', |
| 16 | 'warning_level=1'], |
| 17 | license : 'Public Domain', |
| 18 | meson_version : '>= 0.49.0') |
| 19 | |
| 20 | |
| 21 | jsoncpp_headers = files([ |
| 22 | 'include/json/allocator.h', |
| 23 | 'include/json/assertions.h', |
| 24 | 'include/json/config.h', |
| 25 | 'include/json/json_features.h', |
| 26 | 'include/json/forwards.h', |
| 27 | 'include/json/json.h', |
| 28 | 'include/json/reader.h', |
| 29 | 'include/json/value.h', |
| 30 | 'include/json/version.h', |
| 31 | 'include/json/writer.h', |
| 32 | ]) |
| 33 | jsoncpp_include_directories = include_directories('include') |
| 34 | |
| 35 | install_headers( |
| 36 | jsoncpp_headers, |
| 37 | subdir : 'json') |
| 38 | |
| 39 | if get_option('default_library') == 'shared' and meson.get_compiler('cpp').get_id() == 'msvc' |
| 40 | dll_export_flag = '-DJSON_DLL_BUILD' |
| 41 | dll_import_flag = '-DJSON_DLL' |
| 42 | else |
| 43 | dll_export_flag = [] |
| 44 | dll_import_flag = [] |
| 45 | endif |
| 46 | |
| 47 | jsoncpp_lib = library( |
| 48 | 'jsoncpp', files([ |
| 49 | 'src/lib_json/json_reader.cpp', |
| 50 | 'src/lib_json/json_value.cpp', |
| 51 | 'src/lib_json/json_writer.cpp', |
| 52 | ]), |
Elliott Hughes | 1601ea0 | 2021-12-07 09:43:38 -0800 | [diff] [blame] | 53 | soversion : 25, |
Haibo Huang | b0bee82 | 2021-02-24 15:40:15 -0800 | [diff] [blame] | 54 | install : true, |
| 55 | include_directories : jsoncpp_include_directories, |
| 56 | cpp_args: dll_export_flag) |
| 57 | |
| 58 | import('pkgconfig').generate( |
| 59 | libraries : jsoncpp_lib, |
| 60 | version : meson.project_version(), |
| 61 | name : 'jsoncpp', |
| 62 | filebase : 'jsoncpp', |
| 63 | description : 'A C++ library for interacting with JSON') |
| 64 | |
| 65 | # for libraries bundling jsoncpp |
| 66 | jsoncpp_dep = declare_dependency( |
| 67 | include_directories : jsoncpp_include_directories, |
| 68 | link_with : jsoncpp_lib, |
| 69 | version : meson.project_version()) |
| 70 | |
| 71 | # tests |
| 72 | if meson.is_subproject() or not get_option('tests') |
| 73 | subdir_done() |
| 74 | endif |
| 75 | |
| 76 | python = import('python').find_installation() |
| 77 | |
| 78 | jsoncpp_test = executable( |
| 79 | 'jsoncpp_test', files([ |
| 80 | 'src/test_lib_json/jsontest.cpp', |
| 81 | 'src/test_lib_json/main.cpp', |
| 82 | 'src/test_lib_json/fuzz.cpp', |
| 83 | ]), |
| 84 | include_directories : jsoncpp_include_directories, |
| 85 | link_with : jsoncpp_lib, |
| 86 | install : false, |
| 87 | cpp_args: dll_import_flag) |
| 88 | test( |
| 89 | 'unittest_jsoncpp_test', |
| 90 | jsoncpp_test) |
| 91 | |
| 92 | jsontestrunner = executable( |
| 93 | 'jsontestrunner', |
| 94 | 'src/jsontestrunner/main.cpp', |
| 95 | include_directories : jsoncpp_include_directories, |
| 96 | link_with : jsoncpp_lib, |
| 97 | install : false, |
| 98 | cpp_args: dll_import_flag) |
| 99 | test( |
| 100 | 'unittest_jsontestrunner', |
| 101 | python, |
| 102 | args : [ |
| 103 | '-B', |
| 104 | join_paths(meson.current_source_dir(), 'test/runjsontests.py'), |
| 105 | jsontestrunner, |
| 106 | join_paths(meson.current_source_dir(), 'test/data')], |
| 107 | ) |
| 108 | test( |
| 109 | 'jsonchecker_jsontestrunner', |
| 110 | python, |
| 111 | is_parallel : false, |
| 112 | args : [ |
| 113 | '-B', |
| 114 | join_paths(meson.current_source_dir(), 'test/runjsontests.py'), |
| 115 | '--with-json-checker', |
| 116 | jsontestrunner, |
| 117 | join_paths(meson.current_source_dir(), 'test/data')], |
| 118 | workdir : join_paths(meson.current_source_dir(), 'test/data'), |
| 119 | ) |