spa: declare a dependency for each used library in meson.build

For SPA libraries that we link against elsewhere in the tree, declare a
declare a dependency "foo_dep" for that library that specifies how to
link to it. Then use that dependency in the various targets.

This removes the knowledge of how to link with the library from the
target which can treat it as just another dependency.

In the case of optional libraries (e.g. the journal support lib) we can
then use declare_dependency() to declare an empty dependencies and thus
link them unconditionally in the target.
This commit is contained in:
Peter Hutterer 2021-09-20 08:59:49 +10:00 committed by Wim Taymans
parent 56193d474c
commit 0cbd56f0cd
5 changed files with 15 additions and 13 deletions

View file

@ -19,3 +19,4 @@ acp_lib = static_library(
include_directories : [configinc, spa_inc, includes_inc ],
dependencies : [ alsa_dep, mathlib, ]
)
acp_dep = declare_dependency(link_with: acp_lib)

View file

@ -30,8 +30,7 @@ executable('spa-acp-tool',
[ 'acp-tool.c' ],
c_args : acp_c_args,
include_directories : [spa_inc ],
dependencies : [ alsa_dep, mathlib ],
link_with : [ acp_lib ],
dependencies : [ alsa_dep, mathlib, acp_dep ],
install : true,
)

View file

@ -87,7 +87,7 @@ if have_neon
simd_dependencies += audioconvert_neon
endif
audioconvert = static_library('audioconvert',
audioconvert_lib = static_library('audioconvert',
['fmt-ops.c',
'biquad.c',
'crossover.c',
@ -103,15 +103,16 @@ audioconvert = static_library('audioconvert',
include_directories : [configinc, spa_inc],
install : false
)
audioconvert_dep = declare_dependency(link_with: audioconvert_lib)
audioconvertlib = shared_library('spa-audioconvert',
spa_audioconvert_lib = shared_library('spa-audioconvert',
audioconvert_sources,
c_args : simd_cargs,
include_directories : [spa_inc],
dependencies : [ mathlib ],
link_with : audioconvert,
dependencies : [ mathlib, audioconvert_dep ],
install : true,
install_dir : spa_plugindir / 'audioconvert')
spa_audioconvert_dep = declare_dependency(link_with: spa_audioconvert_lib)
test_lib = static_library('test_lib',
['test-source.c' ],
@ -131,9 +132,9 @@ test_apps = [
foreach a : test_apps
test(a,
executable(a, a + '.c',
dependencies : [dl_lib, pthread_lib, mathlib ],
dependencies : [ dl_lib, pthread_lib, mathlib, audioconvert_dep, spa_audioconvert_dep ],
include_directories : [ configinc, spa_inc ],
link_with : [ audioconvert, test_lib, audioconvertlib ],
link_with : [ test_lib ],
install_rpath : spa_plugindir / 'audioconvert',
c_args : [ simd_cargs ],
install : installed_tests_enabled,
@ -162,10 +163,9 @@ benchmark_apps = [
foreach a : benchmark_apps
benchmark(a,
executable(a, a + '.c',
dependencies : [dl_lib, pthread_lib, mathlib, ],
dependencies : [ dl_lib, pthread_lib, mathlib, audioconvert_dep, spa_audioconvert_dep ],
include_directories : [ configinc, spa_inc ],
c_args : [ simd_cargs ],
link_with : [ audioconvert, audioconvertlib ],
install_rpath : spa_plugindir / 'audioconvert',
install : installed_tests_enabled,
install_dir : installed_tests_execdir / 'audioconvert'),
@ -193,8 +193,8 @@ if sndfile_dep.found()
sparesample_sources,
c_args : [ simd_cargs ],
include_directories : [spa_inc ],
link_with : [ audioconvert, test_lib ],
dependencies : [sndfile_dep, mathlib],
link_with : [ test_lib ],
dependencies : [sndfile_dep, mathlib, audioconvert_dep],
install : true,
)
endif

View file

@ -14,6 +14,7 @@ spa_support_lib = shared_library('spa-support',
dependencies : [ pthread_lib, epoll_shim_dep ],
install : true,
install_dir : spa_plugindir / 'support')
spa_support_dep = declare_dependency(link_with: spa_support_lib)
if not get_option('evl').disabled()

View file

@ -87,7 +87,8 @@ test('test support',
'test-support.c',
'test-logger.c',
include_directories: pwtest_inc,
link_with: [pwtest_lib, spa_support_lib])
dependencies: [systemd_dep, spa_support_dep],
link_with: [pwtest_lib])
)
test('test spa',
executable('test-spa',