aboutsummaryrefslogtreecommitdiff
path: root/contrib/meson/meson/lib/meson.build
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/meson/meson/lib/meson.build')
-rw-r--r--contrib/meson/meson/lib/meson.build91
1 files changed, 55 insertions, 36 deletions
diff --git a/contrib/meson/meson/lib/meson.build b/contrib/meson/meson/lib/meson.build
index 131edcb6..469cd091 100644
--- a/contrib/meson/meson/lib/meson.build
+++ b/contrib/meson/meson/lib/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
@@ -7,51 +8,69 @@
# in the COPYING file in the root directory of this source tree).
# #############################################################################
-lz4_root_dir = '../../../..'
-
-liblz4_includes = [include_directories(join_paths(lz4_root_dir, 'lib'))]
-liblz4_sources = [join_paths(lz4_root_dir, 'lib/lz4.c'),
- join_paths(lz4_root_dir, 'lib/lz4frame.c'),
- join_paths(lz4_root_dir, 'lib/lz4hc.c'),
- join_paths(lz4_root_dir, 'lib/xxhash.c')]
-liblz4_c_args = []
-
-liblz4_debug_cflags = []
-if use_debug
- liblz4_c_args += '-DLZ4_DEBUG=@0@'.format(debug_level)
- if [compiler_gcc, compiler_clang].contains(cc_id)
- liblz4_debug_cflags = ['-Wextra', '-Wcast-qual', '-Wcast-align', '-Wshadow',
- '-Wswitch-enum', '-Wdeclaration-after-statement', '-Wstrict-prototypes',
- '-Wundef', '-Wpointer-arith', '-Wstrict-aliasing=1']
- endif
+lz4_source_root = '../../../..'
+
+sources = files(
+ lz4_source_root / 'lib/lz4.c',
+ lz4_source_root / 'lib/lz4frame.c',
+ lz4_source_root / 'lib/lz4hc.c',
+ lz4_source_root / 'lib/xxhash.c'
+)
+
+c_args = []
+
+if host_machine.system() == 'windows' and get_option('default_library') != 'static'
+ c_args += '-DLZ4_DLL_EXPORT=1'
endif
-liblz4_c_args += cc.get_supported_arguments(liblz4_debug_cflags)
-if host_machine_os == os_windows and default_library != 'static'
- liblz4_c_args += '-DLZ4_DLL_EXPORT=1'
+if get_option('unstable')
+ compile_args += '-DLZ4_STATIC_LINKING_ONLY'
+ if get_option('default_library') != 'static'
+ c_args += '-DLZ4_PUBLISH_STATIC_FUNCTIONS'
+ endif
endif
-liblz4 = library('lz4',
- liblz4_sources,
- include_directories: liblz4_includes,
- c_args: liblz4_c_args,
+liblz4 = library(
+ 'lz4',
+ sources,
install: true,
- version: lz4_libversion)
+ version: lz4_version,
+ gnu_symbol_visibility: 'hidden'
+)
+
+liblz4_dep = declare_dependency(
+ link_with: liblz4,
+ include_directories: include_directories(lz4_source_root / 'lib')
+)
-liblz4_dep = declare_dependency(link_with: liblz4,
- include_directories: liblz4_includes)
+if get_option('tests') or get_option('programs') or get_option('examples')
+ liblz4_internal = static_library(
+ 'lz4-internal',
+ objects: liblz4.extract_all_objects(recursive: true),
+ gnu_symbol_visibility: 'hidden'
+ )
+
+ liblz4_internal_dep = declare_dependency(
+ link_with: liblz4_internal,
+ include_directories: include_directories(lz4_source_root / 'lib')
+ )
+endif
-pkgconfig.generate(liblz4,
+pkgconfig.generate(
+ liblz4,
name: 'lz4',
filebase: 'liblz4',
description: 'extremely fast lossless compression algorithm library',
- version: lz4_libversion,
- url: 'http://www.lz4.org/')
+ version: lz4_version,
+ url: 'http://www.lz4.org/'
+)
-install_headers(join_paths(lz4_root_dir, 'lib/lz4.h'),
- join_paths(lz4_root_dir, 'lib/lz4hc.h'),
- join_paths(lz4_root_dir, 'lib/lz4frame.h'))
+install_headers(
+ lz4_source_root / 'lib/lz4.h',
+ lz4_source_root / 'lib/lz4hc.h',
+ lz4_source_root / 'lib/lz4frame.h'
+)
-if default_library != 'shared'
- install_headers(join_paths(lz4_root_dir, 'lib/lz4frame_static.h'))
+if get_option('default_library') != 'shared'
+ install_headers(lz4_source_root / 'lib/lz4frame_static.h')
endif