aboutsummaryrefslogtreecommitdiff
path: root/contrib/meson/meson/meson.build
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/meson/meson/meson.build')
-rw-r--r--contrib/meson/meson/meson.build122
1 files changed, 36 insertions, 86 deletions
diff --git a/contrib/meson/meson/meson.build b/contrib/meson/meson/meson.build
index b278b7c4..9e8b8c69 100644
--- a/contrib/meson/meson/meson.build
+++ b/contrib/meson/meson/meson.build
@@ -1,5 +1,6 @@
# #############################################################################
-# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
+# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
+# Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
@@ -8,110 +9,59 @@
# #############################################################################
cc = meson.get_compiler('c')
-pkgconfig = import('pkgconfig')
-c_std = get_option('c_std')
-default_library = get_option('default_library')
-host_machine_os = host_machine.system()
-os_windows = 'windows'
-os_linux = 'linux'
-os_darwin = 'darwin'
-os_freebsd = 'freebsd'
-os_sun = 'sunos'
+pkgconfig = import('pkgconfig')
-cc_id = cc.get_id()
-compiler_gcc = 'gcc'
-compiler_clang = 'clang'
-compiler_msvc = 'msvc'
+lz4_source_root = '../../..'
lz4_version = meson.project_version()
-lz4_h_file = join_paths(meson.current_source_dir(), '../../../lib/lz4.h')
-GetLz4LibraryVersion_py = find_program('GetLz4LibraryVersion.py', native : true)
-r = run_command(GetLz4LibraryVersion_py, lz4_h_file)
-if r.returncode() == 0
- lz4_version = r.stdout().strip()
- message('Project version is now: @0@'.format(lz4_version))
-else
- error('Cannot find project version in @0@'.format(lz4_h_file))
+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')),
+ ]
+ ),
+ language: 'c',
+ )
endif
-lz4_libversion = lz4_version
-
-# =============================================================================
-# Installation directories
-# =============================================================================
-
-lz4_prefix = get_option('prefix')
-lz4_bindir = get_option('bindir')
-lz4_datadir = get_option('datadir')
-lz4_mandir = get_option('mandir')
-lz4_docdir = join_paths(lz4_datadir, 'doc', meson.project_name())
-
-# =============================================================================
-# Project options
-# =============================================================================
-
-buildtype = get_option('buildtype')
-
-# Built-in options
-use_debug = get_option('debug')
-
-# Custom options
-debug_level = get_option('debug_level')
-use_backtrace = get_option('backtrace')
-
-bin_programs = get_option('bin_programs')
-bin_contrib = get_option('bin_contrib')
-bin_tests = get_option('bin_tests')
-bin_examples = get_option('bin_examples')
-#feature_multi_thread = get_option('multi_thread')
-
-# =============================================================================
-# Dependencies
-# =============================================================================
-
-#libm_dep = cc.find_library('m', required: bin_tests)
-#thread_dep = dependency('threads', required: feature_multi_thread)
-#use_multi_thread = thread_dep.found()
-
-# =============================================================================
-# Compiler flags
-# =============================================================================
-
-add_project_arguments(['-DXXH_NAMESPACE=LZ4_'], language: 'c')
-
-if [compiler_gcc, compiler_clang].contains(cc_id)
- common_warning_flags = []
- # Should use Meson's own --werror build option
- #common_warning_flags += ['-Werror']
- if c_std == 'c89' or c_std == 'gnu89'
- common_warning_flags += ['-pedantic', '-Wno-long-long', '-Wno-variadic-macros']
- elif c_std == 'c99' or c_std == 'gnu99'
- common_warning_flags += ['-pedantic']
- endif
- cc_compile_flags = cc.get_supported_arguments(common_warning_flags)
- add_project_arguments(cc_compile_flags, language: 'c')
+if get_option('memory-usage') > 0
+ add_project_arguments(
+ '-DLZ4_MEMORY_USAGE=@0@'.format(get_option('memory-usage')),
+ language: 'c'
+ )
endif
-# =============================================================================
-# Subdirs
-# =============================================================================
-
subdir('lib')
-if bin_programs
+if get_option('programs')
subdir('programs')
endif
-if bin_tests
+if get_option('tests')
subdir('tests')
endif
-if bin_contrib
+if get_option('contrib')
subdir('contrib')
endif
-if bin_examples
+if get_option('examples')
subdir('examples')
endif