From ea081f509dd1940835c56d9662086234f5f8c670 Mon Sep 17 00:00:00 2001 From: Chris Cannam Date: Mon, 31 Oct 2022 12:03:46 +0000 Subject: [PATCH] Experiment with Meson's built-in features support for optional targets --- COMPILING.md | 37 +++++++++++++++++++++++++++++++++++++ meson.build | 22 ++++++++++++---------- meson_options.txt | 6 ++++++ 3 files changed, 55 insertions(+), 10 deletions(-) diff --git a/COMPILING.md b/COMPILING.md index 557aa13..5c5a1ee 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -58,6 +58,43 @@ $ meson build -Dipp_path=/opt/intel/ipp The options are documented in the library- and platform-specific 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 compiler. It is unlikely to make any difference (performance or otherwise) which C++ standard you compile with, as long as it's no diff --git a/meson.build b/meson.build index 43cbf33..c615284 100644 --- a/meson.build +++ b/meson.build @@ -117,13 +117,15 @@ sleef_dep = dependency('sleef', 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) 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') -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', prefix: '#define _GNU_SOURCE\n#include ', args: '-lm') @@ -142,7 +144,7 @@ have_sincos = cpp.has_function('sincos', # language pack, optionally, and only go on to JNI if that succeeds, # 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 jni_dep = dependency('jni', version: '>= 7.0.0', required: false) if not jni_dep.found() @@ -375,13 +377,13 @@ if not vamp_dep.found() dirs: get_option('extra_lib_dirs'), has_headers: ['vamp-sdk.h'], header_args: extra_include_args, - required: false) + required: get_option('vamp')) if not vamp_dep.found() vamp_dep = cpp.find_library('vamp-sdk', dirs: get_option('extra_lib_dirs'), has_headers: ['vamp-sdk.h'], header_args: extra_include_args, - required: false) + required: get_option('vamp')) endif endif have_vamp = vamp_dep.found() @@ -391,13 +393,13 @@ if not sndfile_dep.found() dirs: get_option('extra_lib_dirs'), has_headers: ['sndfile.h'], header_args: extra_include_args, - required: false) + required: get_option('cmdline')) if not sndfile_dep.found() sndfile_dep = cpp.find_library('sndfile-1', dirs: get_option('extra_lib_dirs'), has_headers: ['sndfile.h'], header_args: extra_include_args, - required: false) + required: get_option('cmdline')) endif endif have_sndfile = sndfile_dep.found() diff --git a/meson_options.txt b/meson_options.txt index e44837c..0b2ab15 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -26,3 +26,9 @@ option('extra_lib_dirs', value: [], 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')