1project( 2 'json-c', 3 'c', 4 version: '0.18', 5 license: 'MIT', 6 meson_version: '>=0.49', 7 default_options: [ 8 meson.version().version_compare('>=1.3.0') ? 'c_std=gnu99,c99' : 'c_std=gnu99', 9 ], 10) 11 12cc = meson.get_compiler('c') 13 14if cc.get_argument_syntax() == 'msvc' 15 add_project_arguments('-D_CRT_SECURE_NO_WARNINGS', language: 'c') 16else 17 add_project_arguments('-D_GNU_SOURCE', language: 'c') 18endif 19 20if get_option('default_library') != 'static' 21 add_project_arguments('-DJSON_C_DLL', language: 'c') 22endif 23 24add_project_arguments( 25 cc.get_supported_arguments('-Wno-deprecated-declarations'), 26 language: 'c', 27) 28 29threads = dependency('threads', required: false) 30math = cc.find_library('m', required: false) 31 32subdir('config') 33inc = include_directories('config') 34 35json_config = configuration_data() 36if conf.has('HAVE_INTTYPES_H') 37 json_config.set('JSON_C_HAVE_INTTYPES_H', 1) 38endif 39json_config_h = configure_file( 40 configuration: json_config, 41 output: 'json_config.h', 42) 43 44jconf = configuration_data() 45jconf.set('JSON_H_JSON_POINTER', '#include "json_pointer.h"') 46jconf.set('JSON_H_JSON_PATCH', '#include "json_patch.h"') 47 48json_h = configure_file( 49 input: 'json.h.cmakein', 50 output: 'json.h', 51 format: 'cmake@', 52 configuration: jconf, 53) 54 55public_headers = [ 56 json_config_h, 57 json_h, 58 'arraylist.h', 59 'debug.h', 60 'json_c_version.h', 61 'json_inttypes.h', 62 'json_object.h', 63 'json_pointer.h', 64 'json_tokener.h', 65 'json_util.h', 66 'linkhash.h', 67 'printbuf.h', 68] 69 70sources = files( 71 'arraylist.c', 72 'debug.c', 73 'json_c_version.c', 74 'json_object.c', 75 'json_object_iterator.c', 76 'json_pointer.c', 77 'json_tokener.c', 78 'json_util.c', 79 'json_visit.c', 80 'linkhash.c', 81 'printbuf.c', 82 'random_seed.c', 83 'strerror_override.c', 84) 85 86libjson_c = library( 87 'json-c', 88 sources, 89 include_directories: inc, 90 install: true, 91 version: '5.4.0', 92) 93 94json_c_dep = declare_dependency( 95 link_with: libjson_c, 96 include_directories: include_directories('.', '..'), 97 dependencies: [math, threads], 98 sources: json_config_h, 99) 100 101install_headers(public_headers, subdir: 'json-c') 102 103pkgconfig = import('pkgconfig') 104pkgconfig.generate( 105 libjson_c, 106 description: 'A JSON implementation in C', 107 version: meson.project_version(), 108 filebase: meson.project_name(), 109 name: meson.project_name(), 110 subdirs: 'json-c', 111) 112