summaryrefslogtreecommitdiffstats
path: root/meson.build
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-01-11 02:35:06 +0100
committerDavid Robillard <d@drobilla.net>2021-03-24 10:58:32 -0400
commit52cd7ee00e64a021128034da5855a88be52f0871 (patch)
tree676708459122aeeaf65c9d4c05a39798e7c4be6f /meson.build
parent71a2ff5170caaa052814cce19b3de927d10d0e24 (diff)
downloadlilv-52cd7ee00e64a021128034da5855a88be52f0871.tar.gz
lilv-52cd7ee00e64a021128034da5855a88be52f0871.tar.bz2
lilv-52cd7ee00e64a021128034da5855a88be52f0871.zip
WIP: Switch to Meson
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build238
1 files changed, 238 insertions, 0 deletions
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..788142c
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,238 @@
+project('lilv', ['c'],
+ version: '0.24.13',
+ license: 'ISC',
+ meson_version: '>= 0.49.2',
+ default_options: [
+ 'b_ndebug=if-release',
+ 'buildtype=release',
+ 'c_std=c99',
+ 'default_library=shared',
+ 'warning_level=2',
+ ])
+
+lilv_src_root = meson.current_source_dir()
+major_version = meson.project_version().split('.')[0]
+version_suffix = '-@0@'.format(major_version)
+versioned_name = 'lilv' + 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')
+ subdir('meson')
+
+ c_warnings = all_c_warnings
+ if cc.get_id() == 'clang'
+ c_warnings += [
+ '-Wno-cast-align',
+ '-Wno-cast-qual',
+ '-Wno-documentation-unknown-command',
+ '-Wno-double-promotion',
+ '-Wno-float-equal',
+ '-Wno-format-nonliteral',
+ '-Wno-implicit-float-conversion',
+ '-Wno-implicit-int-conversion',
+ '-Wno-nullability-extension',
+ '-Wno-nullable-to-nonnull-conversion',
+ '-Wno-padded',
+ '-Wno-reserved-id-macro',
+ '-Wno-shorten-64-to-32',
+ '-Wno-sign-conversion',
+ '-Wno-switch-enum',
+ '-Wno-vla',
+ ]
+ elif cc.get_id() == 'gcc'
+ c_warnings += [
+ '-Wno-cast-align',
+ '-Wno-cast-qual',
+ '-Wno-conversion',
+ '-Wno-double-promotion',
+ '-Wno-float-equal',
+ '-Wno-format-nonliteral',
+ '-Wno-format-truncation',
+ '-Wno-padded',
+ '-Wno-stack-protector',
+ '-Wno-suggest-attribute=const',
+ '-Wno-suggest-attribute=pure',
+ '-Wno-switch-default',
+ '-Wno-switch-enum',
+ '-Wno-unsuffixed-float-constants',
+ '-Wno-unused-const-variable',
+ '-Wno-unused-parameter',
+ '-Wno-vla',
+ ]
+ 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
+ '/wd4774', # format string is not a string literal
+ '/wd4820', # padding added after construct
+ '/wd4996', # POSIX name for this item is deprecated
+ ]
+ endif
+
+ add_project_arguments(cc.get_supported_arguments(c_warnings),
+ language: ['c'])
+endif
+
+# Add special arguments for MSVC
+if cc.get_id() == 'msvc'
+ msvc_args = [
+ '/D_CRT_SECURE_NO_WARNINGS',
+ '/TP',
+ '/experimental:external',
+ '/external:W0',
+ '/external:anglebrackets',
+ ]
+
+ add_project_arguments(msvc_args, language: ['c'])
+endif
+
+c_headers = ['include/lilv/lilv.h']
+c_header_files = files(c_headers)
+
+sources = [
+ 'src/collections.c',
+ 'src/filesystem.c',
+ 'src/instance.c',
+ 'src/lib.c',
+ 'src/node.c',
+ 'src/plugin.c',
+ 'src/pluginclass.c',
+ 'src/port.c',
+ 'src/query.c',
+ 'src/scalepoint.c',
+ 'src/state.c',
+ 'src/ui.c',
+ 'src/util.c',
+ 'src/world.c',
+ 'src/zix/tree.c',
+]
+
+# System libraries
+m_dep = cc.find_library('m', required: false)
+dl_dep = cc.find_library('dl', required: false)
+
+# Dependencies
+
+lv2_dep = dependency('lv2',
+ version: '>= 1.18.2',
+ fallback: ['lv2', 'lv2_dep'])
+
+serd_dep = dependency('serd-0',
+ version: '>= 0.30.9',
+ fallback: ['serd', 'serd_dep'])
+
+sord_dep = dependency('sord-0',
+ version: '>= 0.16.9',
+ fallback: ['sord', 'sord_dep'])
+
+sratom_dep = dependency('sratom-0',
+ version: '>=0.6.9',
+ fallback: ['sratom', 'sratom_dep'])
+
+# 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')
+ endif
+
+ library_type = 'both_libraries'
+ library_args = ['-DLILV_INTERNAL']
+ prog_args = []
+elif get_option('default_library') == 'shared'
+ library_type = 'shared_library'
+ library_args = ['-DLILV_INTERNAL']
+ prog_args = []
+else
+ library_type = 'static_library'
+ library_args = ['-DLILV_INTERNAL', '-DLILV_STATIC']
+ prog_args = ['-DLILV_STATIC']
+endif
+
+# Build shared and/or static library/libraries
+liblilv = build_target(
+ versioned_name,
+ sources,
+ version: meson.project_version(),
+ include_directories: include_directories(['include', 'src']),
+ c_args: library_args,
+ dependencies: [m_dep, dl_dep, lv2_dep, serd_dep, sord_dep, sratom_dep],
+ gnu_symbol_visibility: 'hidden',
+ install: true,
+ target_type: library_type)
+
+lilv_dep = declare_dependency(
+ include_directories: include_directories(['include']),
+ dependencies: [m_dep, dl_dep, lv2_dep, serd_dep, sord_dep, sratom_dep],
+ link_with: liblilv)
+
+pkg.generate(
+ liblilv,
+ name: 'Lilv',
+ filebase: versioned_name,
+ subdirs: [versioned_name],
+ version: meson.project_version(),
+ description: 'A library for hosting LV2 plugins')
+
+# Build lilvi command line utility
+# if get_option('utils')
+
+# lilvi = executable('lilvi', 'src/lilvi.c',
+# c_args: prog_args,
+# install: true,
+# dependencies: lilv_dep)
+
+# if not get_option('docs').disabled()
+# install_man('doc/lilvi.1')
+# endif
+
+# endif
+
+# Install header to a versioned include directory
+install_headers(c_headers, subdir: versioned_name / 'lilv')
+
+# if not get_option('docs').disabled()
+# subdir('doc')
+# endif
+
+if get_option('tests')
+ if library_type == 'both_libraries'
+ liblilv_static = liblilv.get_static_lib()
+ elif library_type == 'shared_library'
+ liblilv_static = static_library(
+ versioned_name,
+ sources,
+ include_directories: include_directories(['include', 'src']),
+ c_args: library_args,
+ dependencies: [m_dep, dl_dep, lv2_dep, serd_dep, sord_dep, sratom_dep],
+ gnu_symbol_visibility: 'default')
+ else
+ liblilv_static = liblilv
+ endif
+
+ lilv_static_dep = declare_dependency(
+ include_directories: include_directories(['include']),
+ dependencies: [m_dep, dl_dep, lv2_dep, serd_dep, sord_dep, sratom_dep],
+ link_with: liblilv_static)
+
+ subdir('test')
+endif
+
+if not meson.is_subproject() and 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'))
+ endif
+endif