meson: Get rid of cmake and manual library searching

Simplify fallback, and prefer it. `[provide]` section requires meson
0.55, so require that.

pkg-config lookup is only provided for distros, since they dislike
static linking / vendoring.
This commit is contained in:
Nirbheek Chauhan 2023-05-26 00:18:11 +05:30
parent ca1186946d
commit 8366ff0ce0

View File

@ -1,6 +1,6 @@
project('webrtc-audio-processing', 'c', 'cpp', project('webrtc-audio-processing', 'c', 'cpp',
version : '1.1', version : '1.1',
meson_version : '>= 0.54', meson_version : '>= 0.55',
default_options : [ 'warning_level=1', default_options : [ 'warning_level=1',
'buildtype=debugoptimized', 'buildtype=debugoptimized',
'c_std=c11', 'c_std=c11',
@ -41,84 +41,15 @@ have_posix = false
have_win = false have_win = false
# Let's use pkg-config if available. This will also fallback to the subproject # Let's use pkg-config if available. This will also fallback to the subproject
# if pkg-config is not found, instead of CMake or manual library detection. # if pkg-config is not found, which is really the most reliable way of building
# This might be surprising, but is hopefully a temporary state until recent # abseil due to strict C++ standard match requirements.
# abseil versions become the norm.
absl_base_dep = dependency('absl_base', required : false,
fallback: [ 'abseil-cpp', 'absl_base_dep' ]
)
absl_flags_dep = dependency('absl_flags_parse', required : false,
fallback: [ 'abseil-cpp', 'absl_flags_dep' ]
)
absl_optional_dep = dependency('absl_optional', required : false,
fallback: [ 'abseil-cpp', 'absl_types_dep' ]
)
absl_strings_dep = dependency('absl_strings', required : false,
fallback: [ 'abseil-cpp', 'absl_strings_dep' ]
)
absl_synchronization_dep = dependency('absl_synchronization', required : false,
fallback: [ 'abseil-cpp', 'absl_synchronization_dep' ]
)
# If we have the base dep, assume the rest should be present to
if absl_base_dep.found()
absl_dep = [ absl_dep = [
absl_base_dep, dependency('absl_base'),
absl_flags_dep, dependency('absl_flags'),
absl_optional_dep, dependency('absl_types'),
absl_strings_dep, dependency('absl_strings'),
absl_synchronization_dep, dependency('absl_synchronization'),
] ]
else
warning('Could not find abseil-cpp with pkg-config, trying CMake-based library detection.')
absl_dep = dependency('absl', method : 'cmake',
modules : [
'absl::base',
'absl::flags_parse',
'absl::optional',
'absl::strings',
'absl::synchronization',
],
required : false,
)
if not absl_dep.found()
warning('Could not find abseil-cpp with CMake, using fallback library detection which may fail.')
absl_libs = [
'absl_base',
'absl_bad_optional_access',
'absl_city',
'absl_flags_commandlineflag',
'absl_flags_commandlineflag_internal',
'absl_flags_config',
'absl_flags_internal',
'absl_flags_marshalling',
'absl_flags_parse',
'absl_flags_private_handle_accessor',
'absl_flags_program_name',
'absl_flags_reflection',
'absl_flags_usage',
'absl_flags_usage_internal',
'absl_hash',
'absl_int128',
'absl_malloc_internal',
'absl_raw_logging_internal',
'absl_spinlock_wait',
'absl_stacktrace',
'absl_str_format_internal',
'absl_strings',
'absl_symbolize',
'absl_synchronization',
'absl_throw_delegate',
'absl_time',
'absl_time_zone',
]
absl_dep = []
foreach l : absl_libs
absl_dep += cpp.find_library(l, required : false)
endforeach
endif
endif
if ['darwin', 'ios'].contains(host_system) if ['darwin', 'ios'].contains(host_system)
os_cflags = ['-DWEBRTC_MAC'] os_cflags = ['-DWEBRTC_MAC']