meson: Correct support for building on Windows

Let soversion base on version if not set. For example, if version is 3.6.0
and soversion is not defined, it is set to 3.
This commit is contained in:
Lzu Tao 2018-12-05 01:12:11 +07:00
parent 67babb6d23
commit fa2fc274fd
3 changed files with 22 additions and 46 deletions

View File

@ -111,8 +111,7 @@ libzstd = library('zstd',
c_args: libzstd_c_args,
dependencies: libzstd_deps,
install: true,
version: zstd_libversion,
soversion: '1')
version: zstd_libversion)
libzstd_dep = declare_dependency(link_with: libzstd,
include_directories: libzstd_includes)

View File

@ -36,30 +36,30 @@ compiler_clang = 'clang'
compiler_msvc = 'msvc'
zstd_version = meson.project_version()
zstd_libversion = ''
# =============================================================================
# Project directories
# =============================================================================
zstd_h_file = join_paths(meson.current_source_dir(), '../../lib/zstd.h')
GetZstdLibraryVersion_py = files('GetZstdLibraryVersion.py')
r = run_command(python3, GetZstdLibraryVersion_py, zstd_h_file)
if r.returncode() == 0
output = r.stdout().strip()
if output.version_compare('>@0@'.format(zstd_version))
zstd_version = output
message('Project version is now: @0@'.format(zstd_version))
endif
else
message('Cannot find project version in @0@'.format(zstd_h_file))
endif
zstd_rootdir = '../..'
zstd_libversion = zstd_version
# =============================================================================
# Installation directories
# =============================================================================
if host_machine_os == os_windows
zstd_prefix = '.'
zstd_bindir = 'bin'
zstd_datadir = 'share'
zstd_mandir = join_paths(zstd_datadir, 'man')
else
zstd_prefix = get_option('prefix')
zstd_bindir = join_paths(zstd_prefix, get_option('bindir'))
zstd_datadir = join_paths(zstd_prefix, get_option('datadir'))
zstd_mandir = join_paths(zstd_prefix, get_option('mandir'))
endif
zstd_bindir = get_option('bindir')
zstd_datadir = get_option('datadir')
zstd_mandir = get_option('mandir')
zstd_docdir = join_paths(zstd_datadir, 'doc', meson.project_name())
# =============================================================================
@ -85,30 +85,6 @@ feature_zlib = get_option('zlib')
feature_lzma = get_option('lzma')
feature_lz4 = get_option('lz4')
# =============================================================================
# Helper scripts for Meson
# =============================================================================
GetZstdLibraryVersion_py = files('GetZstdLibraryVersion.py')
# =============================================================================
# Getting project version from zstd.h
# =============================================================================
zstd_h_file = join_paths(meson.current_source_dir(), zstd_rootdir, 'lib/zstd.h')
r = run_command(python3, GetZstdLibraryVersion_py, zstd_h_file)
if r.returncode() == 0
output = r.stdout().strip()
if output.version_compare('>@0@'.format(zstd_version))
zstd_version = output
message('Project version is now: @0@'.format(zstd_version))
endif
endif
if host_machine_os != os_windows
zstd_libversion = zstd_version
endif
# =============================================================================
# Dependencies
# =============================================================================

View File

@ -88,14 +88,15 @@ install_man(join_paths(zstd_rootdir, 'programs/zstd.1'),
InstallSymlink_py = '../InstallSymlink.py'
zstd_man1_dir = join_paths(zstd_mandir, 'man1')
man1_EXT = host_machine_os != os_windows ? '.1.gz' : '.1'
bin_EXT = host_machine_os == os_windows ? '.exe' : ''
man1_EXT = '.1.gz' # Meson automatically compresses manpages
foreach f : ['zstdcat', 'unzstd']
meson.add_install_script(InstallSymlink_py, 'zstd', f, zstd_bindir)
meson.add_install_script(InstallSymlink_py, 'zstd' + bin_EXT, f + bin_EXT, zstd_bindir)
meson.add_install_script(InstallSymlink_py, 'zstd' + man1_EXT, f + man1_EXT, zstd_man1_dir)
endforeach
if use_multi_thread
meson.add_install_script(InstallSymlink_py, 'zstd', 'zstdmt', zstd_bindir)
meson.add_install_script(InstallSymlink_py, 'zstd' + bin_EXT, 'zstdmt' + bin_EXT, zstd_bindir)
meson.add_install_script(InstallSymlink_py, 'zstd' + man1_EXT, 'zstdmt' + man1_EXT, zstd_man1_dir)
endif