1 # #############################################################################
2 # Copyright (c) 2018-present Dima Krasner <dima@dimakrasner.com>
3 # lzutao <taolzu(at)gmail.com>
6 # This source code is licensed under both the BSD-style license (found in the
7 # LICENSE file in the root directory of this source tree) and the GPLv2 (found
8 # in the COPYING file in the root directory of this source tree).
9 # #############################################################################
13 license: ['BSD', 'GPLv2'],
15 # There shouldn't be any need to force a C standard convention for zstd
16 # but in case one would want that anyway, this can be done here.
18 # c++11 standard is useful for pzstd
22 # -Wdocumentation does not actually pass, nor do the test binaries,
27 find_program('GetZstdLibraryVersion.py'), '../../lib/zstd.h',
28 check: true).stdout().strip(),
29 meson_version: '>=0.50.0')
31 cc = meson.get_compiler('c')
32 cxx = meson.get_compiler('cpp')
33 pkgconfig = import('pkgconfig')
34 windows_mod = import('windows')
36 host_machine_os = host_machine.system()
37 os_windows = 'windows'
40 os_freebsd = 'freebsd'
45 compiler_clang = 'clang'
46 compiler_msvc = 'msvc'
48 zstd_version = meson.project_version()
50 zstd_libversion = zstd_version
52 # =============================================================================
53 # Installation directories
54 # =============================================================================
56 zstd_prefix = get_option('prefix')
57 zstd_bindir = get_option('bindir')
58 zstd_datadir = get_option('datadir')
59 zstd_mandir = get_option('mandir')
60 zstd_docdir = join_paths(zstd_datadir, 'doc', meson.project_name())
62 # =============================================================================
64 # =============================================================================
67 use_debug = get_option('debug')
68 buildtype = get_option('buildtype')
69 default_library_type = get_option('default_library')
72 debug_level = get_option('debug_level')
73 legacy_level = get_option('legacy_level')
74 use_backtrace = get_option('backtrace')
75 use_static_runtime = get_option('static_runtime')
77 bin_programs = get_option('bin_programs')
78 bin_contrib = get_option('bin_contrib')
79 bin_tests = get_option('bin_tests')
81 feature_multi_thread = get_option('multi_thread')
82 feature_zlib = get_option('zlib')
83 feature_lzma = get_option('lzma')
84 feature_lz4 = get_option('lz4')
86 # =============================================================================
88 # =============================================================================
90 libm_dep = cc.find_library('m', required: false)
91 thread_dep = dependency('threads', required: feature_multi_thread)
92 use_multi_thread = thread_dep.found()
93 # Arguments in dependency should be equivalent to those passed to pkg-config
94 zlib_dep = dependency('zlib', required: feature_zlib)
95 use_zlib = zlib_dep.found()
96 lzma_dep = dependency('liblzma', required: feature_lzma)
97 use_lzma = lzma_dep.found()
98 lz4_dep = dependency('liblz4', required: feature_lz4)
99 use_lz4 = lz4_dep.found()
101 # =============================================================================
103 # =============================================================================
105 add_project_arguments('-DXXH_NAMESPACE=ZSTD_', language: ['c'])
107 pzstd_warning_flags = []
108 if [compiler_gcc, compiler_clang].contains(cc_id)
109 common_warning_flags = [ '-Wundef', '-Wshadow', '-Wcast-align', '-Wcast-qual' ]
110 pzstd_warning_flags = ['-Wno-shadow', '-Wno-deprecated-declarations']
111 if cc_id == compiler_clang
112 common_warning_flags += ['-Wconversion', '-Wno-sign-conversion', '-Wdocumentation']
114 cc_compile_flags = cc.get_supported_arguments(common_warning_flags + ['-Wstrict-prototypes'])
115 cxx_compile_flags = cxx.get_supported_arguments(common_warning_flags)
116 add_project_arguments(cc_compile_flags, language : 'c')
117 add_project_arguments(cxx_compile_flags, language : 'cpp')
118 elif cc_id == compiler_msvc
119 msvc_compile_flags = [ '/D_UNICODE', '/DUNICODE' ]
121 msvc_compile_flags += '/MP'
123 if use_static_runtime
124 msvc_compile_flags += '/MT'
126 add_project_arguments(msvc_compile_flags, language: ['c', 'cpp'])
129 # =============================================================================
131 # =============================================================================
135 if bin_programs or bin_tests