|
| 1 | +project('zlib', 'c', version : '1.4.1.1', license : 'zlib') |
| 2 | + |
| 3 | +cc = meson.get_compiler('c') |
| 4 | + |
| 5 | +link_args = [] |
| 6 | +compile_args = [] |
| 7 | +if cc.get_id() == 'msvc' |
| 8 | + add_project_arguments('-D_CRT_SECURE_NO_DEPRECATE', |
| 9 | + '-D_CRT_NONSTDC_NO_DEPRECATE', language : 'c') |
| 10 | +else |
| 11 | + # Don't spam consumers of this wrap with these warnings |
| 12 | + compile_args += cc.get_supported_arguments(['-Wno-implicit-fallthrough', |
| 13 | + '-Wno-implicit-function-declaration']) |
| 14 | + if cc.get_id() == 'gcc' and host_machine.system() != 'windows' |
| 15 | + vflag = '-Wl,--version-script,@0@/zlib.map'.format(meson.current_source_dir()) |
| 16 | + link_args += [vflag] |
| 17 | + endif |
| 18 | +endif |
| 19 | + |
| 20 | +src = files([ |
| 21 | + 'adler32.c', |
| 22 | + 'crc32.c', |
| 23 | + 'deflate.c', |
| 24 | + 'infback.c', |
| 25 | + 'inffast.c', |
| 26 | + 'inflate.c', |
| 27 | + 'inftrees.c', |
| 28 | + 'trees.c', |
| 29 | + 'zutil.c', |
| 30 | + 'compress.c', |
| 31 | + 'uncompr.c', |
| 32 | + 'gzclose.c', |
| 33 | + 'gzlib.c', |
| 34 | + 'gzread.c', |
| 35 | + 'gzwrite.c']) |
| 36 | + |
| 37 | +headers = files(['zconf.h', 'zlib.h']) |
| 38 | + |
| 39 | +if host_machine.system() == 'windows' and get_option('default_library') != 'static' |
| 40 | + win = import('windows') |
| 41 | + win_args = [] |
| 42 | + if cc.get_id() != 'msvc' |
| 43 | + win_args += '-DGCC_WINDRES' |
| 44 | + endif |
| 45 | + src += win.compile_resources('win32/zlib1.rc', args : win_args) |
| 46 | +endif |
| 47 | + |
| 48 | +if get_option('solo') |
| 49 | + compile_args += ['-DZ_SOLO'] |
| 50 | +endif |
| 51 | + |
| 52 | +zlib = library('z', src, |
| 53 | + c_args : compile_args, |
| 54 | + link_args : link_args, |
| 55 | + vs_module_defs : 'win32/zlib.def', |
| 56 | + install : true) |
| 57 | + |
| 58 | +incdir = include_directories('.') |
| 59 | + |
| 60 | +zlib_dep = declare_dependency( |
| 61 | + link_with : zlib, |
| 62 | + include_directories : incdir) |
| 63 | + |
| 64 | +install_headers(headers) |
| 65 | + |
| 66 | +pkg = import('pkgconfig') |
| 67 | + |
| 68 | +pkg.generate(zlib, |
| 69 | + name: 'zlib', |
| 70 | + description: 'zlib compression library') |
| 71 | + |
| 72 | +meson.override_dependency('zlib', zlib_dep) |
0 commit comments