From b4ac1ec675b79cd05ed7ff2eda8f41002f3a51ef Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 14 Jan 2023 17:41:54 -0500 Subject: Fix and simplify library naming on Windows --- meson.build | 14 ++++++++++++-- meson/library/meson.build | 31 ------------------------------- 2 files changed, 12 insertions(+), 33 deletions(-) delete mode 100644 meson/library/meson.build diff --git a/meson.build b/meson.build index b569c460..b771508e 100644 --- a/meson.build +++ b/meson.build @@ -48,6 +48,16 @@ if host_machine.system() in ['gnu', 'linux'] ] endif +# Use versioned name everywhere to support parallel major version installations +if host_machine.system() == 'windows' + if get_option('default_library') == 'both' + error('default_library=both is not supported on Windows') + endif + soversion = '' +else + soversion = meson.project_version().split('.')[0] +endif + ########### # Library # ########### @@ -73,14 +83,13 @@ sources = files( # Set appropriate arguments for building against the library type extra_c_args = [] -subdir('meson/library') if get_option('default_library') == 'static' extra_c_args = ['-DSERD_STATIC'] endif # Build shared and/or static library libserd = library( - meson.project_name() + library_suffix, + versioned_name, sources, c_args: c_suppressions + extra_c_args + platform_args + [ '-DSERD_INTERNAL', @@ -90,6 +99,7 @@ libserd = library( gnu_symbol_visibility: 'hidden', include_directories: include_dirs, install: true, + soversion: soversion, version: meson.project_version(), ) diff --git a/meson/library/meson.build b/meson/library/meson.build deleted file mode 100644 index 756a222c..00000000 --- a/meson/library/meson.build +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2020-2022 David Robillard -# SPDX-License-Identifier: 0BSD OR ISC - -# General definitions for building libraries. -# -# These are essentially workarounds for Meson/Windows/MSVC. Unfortunately, -# Meson's default_library option doesn't support shared and static builds very -# well. In particular, it's often necessary to define different symbols for -# static and shared builds of libraries so that symbols can be exported. To -# work around this, default_library=both isn't supported on Windows. On other -# platforms with GCC-like compilers, we can support both because symbols can -# safely be exported in the same way (giving them default visibility) in both -# static and shared builds. - -default_library = get_option('default_library') -host_system = host_machine.system() - -# Abort on Windows with default_library=both -if host_system == 'windows' and default_library == 'both' - error('default_library=both is not supported on Windows') -endif - -# Set library_suffix to the suffix for libraries -if host_system == 'windows' and default_library == 'shared' - # Meson appends a version to the name only for DLLs, which leads to - # inconsistent library names, like `mylib-1-1`. So, provide no suffix to - # ultimately get the same name as on other platforms, like `mylib-1`. - library_suffix = '' -else - library_suffix = '-@0@'.format(meson.project_version().split('.')[0]) -endif -- cgit v1.2.1