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