Experiment with Meson's built-in features support for optional targets

This commit is contained in:
Chris Cannam
2022-10-31 12:03:46 +00:00
parent cbc2453743
commit ea081f509d
3 changed files with 55 additions and 10 deletions

View File

@@ -58,6 +58,43 @@ $ meson build -Dipp_path=/opt/intel/ipp
The options are documented in the library- and platform-specific The options are documented in the library- and platform-specific
sections below. sections below.
You can also enable or disable these optional build components:
* `jni` - Java/JVM (JNI) interface to Rubber Band Library
* `ladspa` - LADSPA version of example pitch-shifter plugin
* `lv2` - LV2 version of example pitch-shifter plugin
* `vamp` - Vamp analysis plugin, mostly used for development debugging
* `cmdline` - The `rubberband` and `rubberband-r3` command-line utilities
* `tests` - Unit tests
The default behaviour is to check whether the requirements for these
are found on the system and build them only if they are.
To force a component *not* to be built even when its requirements are
available, set the corresponding flag to `disabled`, e.g.
```
$ meson build -Djni=disabled
```
To require a component to be built (and therefore fail if its
requirements are not met), set it to `enabled`. You can also use the
special Meson `auto_features` flag to set all features to disabled
unless explicitly enabled, e.g.
```
$ meson build -Dauto_features=disabled -Dcmdline=enabled
```
By default the build also produces both static and dynamic library
targets. To force only static or dynamic (shared) output, use one of
```
$ meson build -Ddefault_library=static
$ meson build -Ddefault_library=shared
```
Rubber Band Library is written entirely in C++ and requires a C++11 Rubber Band Library is written entirely in C++ and requires a C++11
compiler. It is unlikely to make any difference (performance or compiler. It is unlikely to make any difference (performance or
otherwise) which C++ standard you compile with, as long as it's no otherwise) which C++ standard you compile with, as long as it's no

View File

@@ -117,13 +117,15 @@ sleef_dep = dependency('sleef', version: '>= 3.3.0', required: false)
sleefdft_dep = dependency('sleefdft', version: '>= 3.3.0', required: false) sleefdft_dep = dependency('sleefdft', version: '>= 3.3.0', required: false)
samplerate_dep = dependency('samplerate', version: '>= 0.1.8', required: false) samplerate_dep = dependency('samplerate', version: '>= 0.1.8', required: false)
speexdsp_dep = dependency('speexdsp', version: '>= 1.0.0', required: false) speexdsp_dep = dependency('speexdsp', version: '>= 1.0.0', required: false)
sndfile_dep = dependency('sndfile', version: '>= 1.0.16', required: false)
vamp_dep = dependency('vamp-sdk', version: '>= 2.9', required: false)
boost_unit_test_dep = dependency('boost', modules: ['unit_test_framework'], version: '>= 1.73', required: false) sndfile_dep = dependency('sndfile', version: '>= 1.0.16', required: get_option('cmdline'))
vamp_dep = dependency('vamp-sdk', version: '>= 2.9', required: get_option('vamp'))
boost_unit_test_dep = dependency('boost', modules: ['unit_test_framework'], version: '>= 1.73', required: get_option('tests'))
thread_dep = dependency('threads') thread_dep = dependency('threads')
have_ladspa = cpp.has_header('ladspa.h', args: extra_include_args)
have_lv2 = cpp.has_header('lv2.h', args: extra_include_args) have_ladspa = cpp.has_header('ladspa.h', args: extra_include_args, required: get_option('ladspa'))
have_lv2 = cpp.has_header('lv2.h', args: extra_include_args, required: get_option('lv2'))
have_sincos = cpp.has_function('sincos', have_sincos = cpp.has_function('sincos',
prefix: '#define _GNU_SOURCE\n#include <math.h>', prefix: '#define _GNU_SOURCE\n#include <math.h>',
args: '-lm') args: '-lm')
@@ -142,7 +144,7 @@ have_sincos = cpp.has_function('sincos',
# language pack, optionally, and only go on to JNI if that succeeds, # language pack, optionally, and only go on to JNI if that succeeds,
# making sure that nothing "clever" happens if Java is not found. # making sure that nothing "clever" happens if Java is not found.
# #
have_java = add_languages('java', required: false) have_java = add_languages('java', required: get_option('jni'))
if have_java if have_java
jni_dep = dependency('jni', version: '>= 7.0.0', required: false) jni_dep = dependency('jni', version: '>= 7.0.0', required: false)
if not jni_dep.found() if not jni_dep.found()
@@ -375,13 +377,13 @@ if not vamp_dep.found()
dirs: get_option('extra_lib_dirs'), dirs: get_option('extra_lib_dirs'),
has_headers: ['vamp-sdk.h'], has_headers: ['vamp-sdk.h'],
header_args: extra_include_args, header_args: extra_include_args,
required: false) required: get_option('vamp'))
if not vamp_dep.found() if not vamp_dep.found()
vamp_dep = cpp.find_library('vamp-sdk', vamp_dep = cpp.find_library('vamp-sdk',
dirs: get_option('extra_lib_dirs'), dirs: get_option('extra_lib_dirs'),
has_headers: ['vamp-sdk.h'], has_headers: ['vamp-sdk.h'],
header_args: extra_include_args, header_args: extra_include_args,
required: false) required: get_option('vamp'))
endif endif
endif endif
have_vamp = vamp_dep.found() have_vamp = vamp_dep.found()
@@ -391,13 +393,13 @@ if not sndfile_dep.found()
dirs: get_option('extra_lib_dirs'), dirs: get_option('extra_lib_dirs'),
has_headers: ['sndfile.h'], has_headers: ['sndfile.h'],
header_args: extra_include_args, header_args: extra_include_args,
required: false) required: get_option('cmdline'))
if not sndfile_dep.found() if not sndfile_dep.found()
sndfile_dep = cpp.find_library('sndfile-1', sndfile_dep = cpp.find_library('sndfile-1',
dirs: get_option('extra_lib_dirs'), dirs: get_option('extra_lib_dirs'),
has_headers: ['sndfile.h'], has_headers: ['sndfile.h'],
header_args: extra_include_args, header_args: extra_include_args,
required: false) required: get_option('cmdline'))
endif endif
endif endif
have_sndfile = sndfile_dep.found() have_sndfile = sndfile_dep.found()

View File

@@ -26,3 +26,9 @@ option('extra_lib_dirs',
value: [], value: [],
description: 'Additional local library directories to search for dependencies.') description: 'Additional local library directories to search for dependencies.')
option('jni', type: 'feature', value: 'auto')
option('ladspa', type: 'feature', value: 'auto')
option('lv2', type: 'feature', value: 'auto')
option('vamp', type: 'feature', value: 'auto')
option('cmdline', type: 'feature', value: 'auto')
option('tests', type: 'feature', value: 'auto')