|
| 1 | +avro_flags = [] |
| 2 | +avro_deps = [] |
| 3 | +avro_public_deps = [] |
| 4 | + |
| 5 | +fmt_dep = dependency( |
| 6 | + 'fmt', |
| 7 | + required: true, |
| 8 | +) |
| 9 | +avro_deps += fmt_dep |
| 10 | +avro_public_deps += fmt_dep |
| 11 | + |
| 12 | +zlib_dep = dependency( |
| 13 | + 'zlib', |
| 14 | + required: true, |
| 15 | +) |
| 16 | +avro_deps += zlib_dep |
| 17 | + |
| 18 | +snappy_dep = dependency( |
| 19 | + 'snappy', |
| 20 | + required: false, |
| 21 | +) |
| 22 | +if snappy_dep.found() |
| 23 | + avro_flags += '-DSNAPPY_CODEC_AVAILABLE' |
| 24 | + avro_deps += snappy_dep |
| 25 | +endif |
| 26 | + |
| 27 | +zstd_dep = dependency( |
| 28 | + 'libzstd', |
| 29 | + required: false, |
| 30 | +) |
| 31 | +if zstd_dep.found() |
| 32 | + avro_flags += '-DZSTD_CODEC_AVAILABLE' |
| 33 | + avro_deps += zstd_dep |
| 34 | +endif |
| 35 | + |
| 36 | +# Set static and shared flags manually since Meson 1.3.0 is still too new |
| 37 | +avro_flags += '-DAVRO_SOURCE' |
| 38 | +if get_option('default_library') == 'shared' |
| 39 | + avro_flags += '-DAVRO_DYN_LINK' |
| 40 | +elif get_option('default_library') == 'both' |
| 41 | + error('Building both static and shared libraries is not possible') |
| 42 | +endif |
| 43 | + |
| 44 | +avro_inc = include_directories('include/avro') |
| 45 | + |
| 46 | +avro_src = files( |
| 47 | + 'impl/BinaryDecoder.cc', |
| 48 | + 'impl/BinaryEncoder.cc', |
| 49 | + 'impl/Compiler.cc', |
| 50 | + 'impl/CustomAttributes.cc', |
| 51 | + 'impl/DataFile.cc', |
| 52 | + 'impl/FileStream.cc', |
| 53 | + 'impl/Generic.cc', |
| 54 | + 'impl/GenericDatum.cc', |
| 55 | + 'impl/LogicalType.cc', |
| 56 | + 'impl/Node.cc', |
| 57 | + 'impl/NodeImpl.cc', |
| 58 | + 'impl/Resolver.cc', |
| 59 | + 'impl/ResolverSchema.cc', |
| 60 | + 'impl/Schema.cc', |
| 61 | + 'impl/Stream.cc', |
| 62 | + 'impl/Types.cc', |
| 63 | + 'impl/ValidSchema.cc', |
| 64 | + 'impl/Validator.cc', |
| 65 | + 'impl/Zigzag.cc', |
| 66 | + 'impl/json/JsonDom.cc', |
| 67 | + 'impl/json/JsonIO.cc', |
| 68 | + 'impl/parsing/JsonCodec.cc', |
| 69 | + 'impl/parsing/ResolvingDecoder.cc', |
| 70 | + 'impl/parsing/Symbol.cc', |
| 71 | + 'impl/parsing/ValidatingCodec.cc', |
| 72 | +) |
| 73 | + |
| 74 | +avro_lib = library( |
| 75 | + 'avrocpp', |
| 76 | + sources: avro_src, |
| 77 | + include_directories: avro_inc, |
| 78 | + cpp_args: avro_flags, |
| 79 | + dependencies: avro_deps, |
| 80 | + version: meson.project_version(), |
| 81 | + install: true, |
| 82 | +) |
| 83 | + |
| 84 | +install_subdir( |
| 85 | + 'include/avro', |
| 86 | + install_dir: get_option('includedir'), |
| 87 | + install_tag: 'devel', |
| 88 | +) |
| 89 | + |
| 90 | +avro_dep = declare_dependency( |
| 91 | + include_directories: avro_inc, |
| 92 | + link_with: avro_lib, |
| 93 | + dependencies: avro_public_deps, |
| 94 | +) |
| 95 | +meson.override_dependency('avro-cpp', avro_dep) |
| 96 | + |
| 97 | +avro_requires = [] |
| 98 | +foreach dep : avro_public_deps |
| 99 | + avro_requires += dep.name() |
| 100 | +endforeach |
| 101 | +import('pkgconfig').generate( |
| 102 | + avro_lib, |
| 103 | + name: meson.project_name(), |
| 104 | + description: 'C++ library for parsing Avro data', |
| 105 | + url: 'https://avro.apache.org/', |
| 106 | + requires: avro_requires, |
| 107 | +) |
| 108 | + |
| 109 | +if get_option('build_executable') |
| 110 | + avrogencpp_exe = executable( |
| 111 | + 'avrogencpp', |
| 112 | + sources: ['impl/avrogencpp.cc'], |
| 113 | + cpp_args: ['-DAVRO_VERSION="@0@"'.format(meson.project_version())], |
| 114 | + dependencies: avro_dep, |
| 115 | + install: true, |
| 116 | + install_tag: 'devel', |
| 117 | + ) |
| 118 | + meson.override_find_program('avrogencpp', avrogencpp_exe) |
| 119 | +endif |
0 commit comments