meson: find dependencies only when necessary

This allows finding dependencies conditionally, only
when the enabled features actually need them.

Also, make sure to require those dependencies when the enabled
features do need them, instead of using "required: false" and
failing later
This commit is contained in:
George Kiagiadakis 2019-01-29 17:39:44 +02:00 committed by Wim Taymans
parent d08ec09dde
commit 58a878623b
2 changed files with 29 additions and 16 deletions

View file

@ -170,8 +170,11 @@ rt_lib = cc.find_library('rt', required : false) # clock_gettime
dl_lib = cc.find_library('dl', required : false)
pthread_lib = dependency('threads')
dbus_dep = dependency('dbus-1')
sdl_dep = dependency('sdl2', required : false)
glib_dep = dependency('glib-2.0', version : '>=2.32.0', required : false)
if get_option('gstreamer') or get_option('pipewire-pulseaudio')
glib_dep = dependency('glib-2.0', version : '>=2.32.0')
endif
if get_option('gstreamer')
gobject_dep = dependency('gobject-2.0')
@ -201,6 +204,7 @@ if get_option('pipewire-pulseaudio')
endif
if get_option('pipewire-alsa')
alsa_dep = dependency('alsa')
subdir('pipewire-alsa/alsa-plugins')
endif

View file

@ -1,20 +1,5 @@
#project('spa', 'c')
alsa_dep = dependency('alsa')
v4l2_dep = dependency('libv4l2')
x11_dep = dependency('x11', required : false)
sdl_dep = dependency('sdl2', required : false)
libva_dep = dependency('libva', required : false)
sbc_dep = dependency('sbc', required : false)
avcodec_dep = dependency('libavcodec', required : false)
avformat_dep = dependency('libavformat', required : false)
avfilter_dep = dependency('libavfilter', required : false)
libudev_dep = dependency('libudev')
threads_dep = dependency('threads')
speexdsp_dep = dependency('speexdsp')
sdl_dep = dependency('sdl2', required : false)
bluez_dep = dependency('bluez', version : '>= 4.101', required : false)
#cc = meson.get_compiler('c')
#dl_lib = cc.find_library('dl', required : false)
#pthread_lib = dependencies('threads')
@ -25,6 +10,30 @@ spa_inc = include_directories('include')
subdir('include')
if get_option('spa-plugins')
# common dependencies
if get_option('alsa') or get_option('v4l2')
libudev_dep = dependency('libudev')
endif
# plugin-specific dependencies
if get_option('alsa')
alsa_dep = dependency('alsa')
endif
if get_option('audioconvert')
speexdsp_dep = dependency('speexdsp')
endif
if get_option('bluez5')
bluez_dep = dependency('bluez', version : '>= 4.101')
sbc_dep = dependency('sbc')
endif
if get_option('ffmpeg')
avcodec_dep = dependency('libavcodec')
avformat_dep = dependency('libavformat')
endif
if get_option('v4l2')
v4l2_dep = dependency('libv4l2')
endif
subdir('plugins')
endif