Serd subproject with meson
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

158 lines
4.3 KiB

project('serd', ['c'],
version: '0.30.9',
license: 'ISC',
meson_version: '>= 0.49.2',
default_options: [
serd_src_root = meson.current_source_dir()
major_version = meson.project_version().split('.')[0]
version_suffix = '-@0@'.format(major_version)
versioned_name = 'serd' + version_suffix
# Load build tools
pkg = import('pkgconfig')
cc = meson.get_compiler('c')
# Set ultra strict warnings for developers, if requested
if get_option('strict')
c_warnings = all_c_warnings
if cc.get_id() == 'clang'
c_warnings += [
elif cc.get_id() == 'gcc'
c_warnings += [
elif cc.get_id() == 'msvc'
c_warnings += [
'/wd4061', # enumerator in switch is not explicitly handled
'/wd4365', # signed/unsigned mismatch
'/wd4514', # unreferenced inline function has been removed
'/wd4706', # assignment within conditional expression
'/wd4710', # function not inlined
'/wd4711', # function selected for automatic inline expansion
'/wd4820', # padding added after construct
'/wd4996', # POSIX name for this item is deprecated
'/wd5045', # will insert Spectre mitigation for memory load
language: ['c'])
# Add special arguments for MSVC
if cc.get_id() == 'msvc'
msvc_args = [
add_project_arguments(msvc_args, language: ['c'])
c_headers = ['include/serd/serd.h']
c_header_files = files(c_headers)
c_header = files('include/serd/serd.h')
sources = [
# System libraries
m_dep = cc.find_library('m', required: false)
# Determine library type and the flags needed to build it
if get_option('default_library') == 'both'
if host_machine.system() == 'windows'
error('default_library=both is not supported on Windows')
library_type = 'both_libraries'
library_args = ['-DSERD_INTERNAL']
prog_args = []
elif get_option('default_library') == 'shared'
library_type = 'shared_library'
library_args = ['-DSERD_INTERNAL']
prog_args = []
library_type = 'static_library'
library_args = ['-DSERD_INTERNAL', '-DSERD_STATIC']
prog_args = ['-DSERD_STATIC']
# Build shared and/or static library/libraries
libserd = build_target(
version: meson.project_version(),
include_directories: include_directories(['include']),
c_args: library_args,
dependencies: m_dep,
gnu_symbol_visibility: 'hidden',
1 year ago
install: false,
target_type: library_type)
serd_dep = declare_dependency(
include_directories: include_directories(['include']),
link_with: libserd)
if meson.version().version_compare('>=0.53.0')
summary('Tests', get_option('tests'), bool_yn: true)
summary('Utilities', get_option('utils'), bool_yn: true)
summary('Install prefix', get_option('prefix'))
summary('Headers', get_option('prefix') / get_option('includedir'))
summary('Libraries', get_option('prefix') / get_option('libdir'))
if get_option('utils')
summary('Executables', get_option('prefix') / get_option('bindir'))
summary('Man pages', get_option('prefix') / get_option('mandir'))