diff options
author | Yann Collet <Cyan4973@users.noreply.github.com> | 2022-10-25 06:47:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-25 06:47:31 (GMT) |
commit | 214bfb325bd4db112b73859912b919aa35e12d61 (patch) | |
tree | b5c04cd31e42772751dac47bc6a0780b581b871d /contrib/meson/meson/meson.build | |
parent | e312412c60140b3d061526499cef22e5e99d7751 (diff) | |
parent | 198e532300f253ada3acac3ab5428ed991adb085 (diff) | |
download | lz4-214bfb325bd4db112b73859912b919aa35e12d61.zip lz4-214bfb325bd4db112b73859912b919aa35e12d61.tar.gz lz4-214bfb325bd4db112b73859912b919aa35e12d61.tar.bz2 |
Merge pull request #1139 from tristan957/meson
Update Meson build to 1.9.4
Diffstat (limited to 'contrib/meson/meson/meson.build')
-rw-r--r-- | contrib/meson/meson/meson.build | 99 |
1 files changed, 79 insertions, 20 deletions
diff --git a/contrib/meson/meson/meson.build b/contrib/meson/meson/meson.build index 9e8b8c6..3bea06d 100644 --- a/contrib/meson/meson/meson.build +++ b/contrib/meson/meson/meson.build @@ -10,48 +10,103 @@ cc = meson.get_compiler('c') +fs = import('fs') pkgconfig = import('pkgconfig') lz4_source_root = '../../..' -lz4_version = meson.project_version() - -lz4_h_file = lz4_source_root / 'lib/lz4.h' -GetLz4LibraryVersion_py = find_program('GetLz4LibraryVersion.py') -lz4_version = run_command(GetLz4LibraryVersion_py, lz4_h_file, check: true).stdout().strip() -message('Project version is now: @0@'.format(lz4_version)) - add_project_arguments('-DXXH_NAMESPACE=LZ4_', language: 'c') if get_option('debug') - add_project_arguments(cc.get_supported_arguments([ - '-Wcast-qual', - '-Wcast-align', - '-Wshadow', - '-Wswitch-enum', - '-Wdeclaration-after-statement', - '-Wstrict-prototypes', - '-Wundef', - '-Wpointer-arith', - '-Wstrict-aliasing=1', - '-DLZ4_DEBUG=@0@'.format(get_option('debug-level')), - ] + add_project_arguments(cc.get_supported_arguments( + '-Wcast-qual', + '-Wcast-align', + '-Wshadow', + '-Wswitch-enum', + '-Wdeclaration-after-statement', + '-Wstrict-prototypes', + '-Wundef', + '-Wpointer-arith', + '-Wstrict-aliasing=1', + '-DLZ4_DEBUG=@0@'.format(get_option('debug-level')) + ), + language: 'c' + ) +endif + +compile_args = [] + +if not get_option('align-test') + add_project_arguments('-DLZ4_ALIGN_TEST=0', language: 'c') +endif + +if get_option('disable-memory-allocation') + if get_option('default_library') != 'static' + error('Memory allocation can only be disabled in static builds') + endif + + add_project_arguments('-DLZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION') + compile_args += '-DLZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION' +endif + +add_project_arguments( + '-DLZ4_DISTANCE_MAX=@0@'.format(get_option('distance-max')), + language: 'c' +) +compile_args += '-DLZ4_DISTANCE_MAX=@0@'.format(get_option('distance-max')) + +if not get_option('fast-dec-loop').auto() + add_project_arguments( + '-DLZ4_FAST_DEC_LOOP=@0@'.format( + get_option('fast-dec-loop').enabled() ? 1 : 0 ), - language: 'c', + language: 'c' ) endif +if get_option('force-sw-bitcount') + add_project_arguments('-DLZ4_FORCE_SW_BITCOUNT', language: 'c') +endif + +if get_option('freestanding') + add_project_arguments('-DLZ4_FREESTANDING=1', language: 'c') + compile_args += '-DLZ4_FREESTANDING=1' +endif + if get_option('memory-usage') > 0 add_project_arguments( '-DLZ4_MEMORY_USAGE=@0@'.format(get_option('memory-usage')), language: 'c' ) + compile_args += '-DLZ4_MEMORY_USAGE=@0@'.format(get_option('memory-usage')) +endif + +if get_option('unstable') + add_project_arguments('-DLZ4_STATIC_LINKING_ONLY', language: 'c') + compile_args += '-DLZ4_STATIC_LINKING_ONLY' + if get_option('default_library') != 'static' + add_project_arguments('-DLZ4_PUBLISH_STATIC_FUNCTIONS', language: 'c') + compile_args += '-DLZ4_PUBLISH_STATIC_FUNCTIONS' + + add_project_arguments('-DLZ4F_PUBLISH_STATIC_FUNCTIONS', language: 'c') + compile_args += '-DLZ4F_PUBLISH_STATIC_FUNCTIONS' + endif +endif + +if get_option('user-memory-functions') + add_project_arguments('-DLZ4_USER_MEMORY_FUNCTIONS', language: 'c') endif +run_env = environment() + subdir('lib') if get_option('programs') subdir('programs') +else + lz4 = disabler() + lz4cat = disabler() + unlz4 = disabler() endif if get_option('tests') @@ -65,3 +120,7 @@ endif if get_option('examples') subdir('examples') endif + +if get_option('ossfuzz') + subdir('ossfuzz') +endif |