2018-11-27 10:04:41 -08:00
|
|
|
# #############################################################################
|
|
|
|
# Copyright (c) 2018-present Dima Krasner <dima@dimakrasner.com>
|
|
|
|
# lzutao <taolzu(at)gmail.com>
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# This source code is licensed under both the BSD-style license (found in the
|
|
|
|
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
|
|
|
# in the COPYING file in the root directory of this source tree).
|
|
|
|
# #############################################################################
|
2017-02-16 09:35:56 -08:00
|
|
|
|
2018-11-27 10:04:41 -08:00
|
|
|
project('zstd',
|
2018-11-30 01:15:33 -08:00
|
|
|
['c', 'cpp'],
|
|
|
|
license: ['BSD', 'GPLv2'],
|
2018-12-27 20:20:33 -08:00
|
|
|
default_options : [
|
2019-05-02 12:35:37 -07:00
|
|
|
'c_std=gnu99',
|
2018-11-30 01:15:33 -08:00
|
|
|
'cpp_std=c++11',
|
2018-12-27 20:20:33 -08:00
|
|
|
'buildtype=release'
|
|
|
|
],
|
2019-04-29 23:12:00 -07:00
|
|
|
version: 'DUMMY',
|
2018-11-30 01:15:33 -08:00
|
|
|
meson_version: '>=0.47.0')
|
2018-11-27 10:04:41 -08:00
|
|
|
|
|
|
|
cc = meson.get_compiler('c')
|
|
|
|
cxx = meson.get_compiler('cpp')
|
|
|
|
pkgconfig = import('pkgconfig')
|
2018-11-30 00:30:45 -08:00
|
|
|
windows_mod = import('windows')
|
|
|
|
|
|
|
|
host_machine_os = host_machine.system()
|
|
|
|
os_windows = 'windows'
|
|
|
|
os_linux = 'linux'
|
|
|
|
os_darwin = 'darwin'
|
|
|
|
os_freebsd = 'freebsd'
|
|
|
|
os_sun = 'sunos'
|
|
|
|
|
|
|
|
cc_id = cc.get_id()
|
|
|
|
compiler_gcc = 'gcc'
|
|
|
|
compiler_clang = 'clang'
|
|
|
|
compiler_msvc = 'msvc'
|
2018-11-27 10:04:41 -08:00
|
|
|
|
|
|
|
zstd_version = meson.project_version()
|
|
|
|
|
2018-12-04 10:12:11 -08:00
|
|
|
zstd_h_file = join_paths(meson.current_source_dir(), '../../lib/zstd.h')
|
2020-06-09 16:33:16 -07:00
|
|
|
GetZstdLibraryVersion_py = find_program('GetZstdLibraryVersion.py', native : true)
|
|
|
|
r = run_command(GetZstdLibraryVersion_py, zstd_h_file)
|
2018-12-04 10:12:11 -08:00
|
|
|
if r.returncode() == 0
|
2019-04-29 23:12:00 -07:00
|
|
|
zstd_version = r.stdout().strip()
|
|
|
|
message('Project version is now: @0@'.format(zstd_version))
|
2018-12-04 10:12:11 -08:00
|
|
|
else
|
2019-04-29 23:12:00 -07:00
|
|
|
error('Cannot find project version in @0@'.format(zstd_h_file))
|
2018-12-04 10:12:11 -08:00
|
|
|
endif
|
2018-11-27 10:04:41 -08:00
|
|
|
|
2018-12-04 10:12:11 -08:00
|
|
|
zstd_libversion = zstd_version
|
2018-11-30 00:30:45 -08:00
|
|
|
|
|
|
|
# =============================================================================
|
2018-11-30 01:15:33 -08:00
|
|
|
# Installation directories
|
2018-11-30 00:30:45 -08:00
|
|
|
# =============================================================================
|
|
|
|
|
2018-12-04 10:12:11 -08:00
|
|
|
zstd_prefix = get_option('prefix')
|
|
|
|
zstd_bindir = get_option('bindir')
|
|
|
|
zstd_datadir = get_option('datadir')
|
|
|
|
zstd_mandir = get_option('mandir')
|
2018-11-30 00:30:45 -08:00
|
|
|
zstd_docdir = join_paths(zstd_datadir, 'doc', meson.project_name())
|
2018-11-27 10:04:41 -08:00
|
|
|
|
|
|
|
# =============================================================================
|
|
|
|
# Project options
|
|
|
|
# =============================================================================
|
2018-11-28 21:52:35 -08:00
|
|
|
|
2018-11-30 06:05:03 -08:00
|
|
|
# Built-in options
|
|
|
|
use_debug = get_option('debug')
|
2018-12-02 07:33:25 -08:00
|
|
|
buildtype = get_option('buildtype')
|
2020-05-01 07:04:09 -07:00
|
|
|
default_library_type = get_option('default_library')
|
2018-11-30 06:05:03 -08:00
|
|
|
|
|
|
|
# Custom options
|
|
|
|
debug_level = get_option('debug_level')
|
|
|
|
legacy_level = get_option('legacy_level')
|
|
|
|
use_backtrace = get_option('backtrace')
|
|
|
|
use_static_runtime = get_option('static_runtime')
|
|
|
|
|
2019-06-28 11:59:57 -07:00
|
|
|
bin_programs = get_option('bin_programs')
|
|
|
|
bin_contrib = get_option('bin_contrib')
|
|
|
|
bin_tests = get_option('bin_tests')
|
2018-11-30 06:05:03 -08:00
|
|
|
|
|
|
|
feature_multi_thread = get_option('multi_thread')
|
|
|
|
feature_zlib = get_option('zlib')
|
|
|
|
feature_lzma = get_option('lzma')
|
|
|
|
feature_lz4 = get_option('lz4')
|
2018-11-27 10:04:41 -08:00
|
|
|
|
|
|
|
# =============================================================================
|
|
|
|
# Dependencies
|
|
|
|
# =============================================================================
|
|
|
|
|
2019-06-28 11:59:57 -07:00
|
|
|
libm_dep = cc.find_library('m', required: bin_tests)
|
2018-11-30 06:05:03 -08:00
|
|
|
thread_dep = dependency('threads', required: feature_multi_thread)
|
|
|
|
use_multi_thread = thread_dep.found()
|
2018-11-28 22:15:18 -08:00
|
|
|
# Arguments in dependency should be equivalent to those passed to pkg-config
|
2018-11-30 06:05:03 -08:00
|
|
|
zlib_dep = dependency('zlib', required: feature_zlib)
|
|
|
|
use_zlib = zlib_dep.found()
|
|
|
|
lzma_dep = dependency('liblzma', required: feature_lzma)
|
|
|
|
use_lzma = lzma_dep.found()
|
|
|
|
lz4_dep = dependency('liblz4', required: feature_lz4)
|
|
|
|
use_lz4 = lz4_dep.found()
|
2018-11-27 10:04:41 -08:00
|
|
|
|
|
|
|
# =============================================================================
|
|
|
|
# Compiler flags
|
|
|
|
# =============================================================================
|
|
|
|
|
2018-11-30 01:15:33 -08:00
|
|
|
add_project_arguments('-DXXH_NAMESPACE=ZSTD_', language: ['c'])
|
2018-11-30 00:30:45 -08:00
|
|
|
|
|
|
|
if [compiler_gcc, compiler_clang].contains(cc_id)
|
2018-11-30 01:15:33 -08:00
|
|
|
common_warning_flags = [ '-Wextra', '-Wundef', '-Wshadow', '-Wcast-align', '-Wcast-qual' ]
|
|
|
|
if cc_id == compiler_clang
|
2018-12-02 07:33:25 -08:00
|
|
|
# Should use Meson's own --werror build option
|
|
|
|
#common_warning_flags += '-Werror'
|
|
|
|
common_warning_flags += ['-Wconversion', '-Wno-sign-conversion', '-Wdocumentation']
|
2018-11-30 01:15:33 -08:00
|
|
|
endif
|
|
|
|
cc_compile_flags = cc.get_supported_arguments(common_warning_flags + ['-Wstrict-prototypes'])
|
|
|
|
cxx_compile_flags = cxx.get_supported_arguments(common_warning_flags)
|
|
|
|
add_project_arguments(cc_compile_flags, language : 'c')
|
|
|
|
add_project_arguments(cxx_compile_flags, language : 'cpp')
|
2018-11-30 00:30:45 -08:00
|
|
|
elif cc_id == compiler_msvc
|
2018-11-30 01:15:33 -08:00
|
|
|
msvc_compile_flags = [ '/D_UNICODE', '/DUNICODE' ]
|
2018-11-30 06:05:03 -08:00
|
|
|
if use_multi_thread
|
2018-11-30 01:15:33 -08:00
|
|
|
msvc_compile_flags += '/MP'
|
|
|
|
endif
|
2020-05-01 07:04:09 -07:00
|
|
|
if use_static_runtime
|
2018-11-30 01:15:33 -08:00
|
|
|
msvc_compile_flags += '/MT'
|
|
|
|
endif
|
|
|
|
add_project_arguments(msvc_compile_flags, language: ['c', 'cpp'])
|
2018-11-27 10:04:41 -08:00
|
|
|
endif
|
|
|
|
|
|
|
|
# =============================================================================
|
|
|
|
# Subdirs
|
|
|
|
# =============================================================================
|
|
|
|
|
|
|
|
subdir('lib')
|
2018-11-27 21:16:09 -08:00
|
|
|
|
2019-06-28 11:59:57 -07:00
|
|
|
if bin_programs
|
2018-11-30 01:15:33 -08:00
|
|
|
subdir('programs')
|
2018-11-27 10:04:41 -08:00
|
|
|
endif
|
|
|
|
|
2019-06-28 11:59:57 -07:00
|
|
|
if bin_tests
|
2018-11-30 01:15:33 -08:00
|
|
|
subdir('tests')
|
2017-02-17 02:27:13 -08:00
|
|
|
endif
|
|
|
|
|
2019-06-28 11:59:57 -07:00
|
|
|
if bin_contrib
|
2018-11-30 01:15:33 -08:00
|
|
|
subdir('contrib')
|
2017-02-16 09:35:56 -08:00
|
|
|
endif
|