gio/tests/{meson.build,pollable.c}: Determine libutil SONAME at build time

Calling `dlopen()` with `libutil.so` makes the installed tests depend on
having glibc's development files installed. To avoid this, we can work
out the runtime library name at build time and `dlopen` that instead.

This approach is [taken from libfprint][1], thanks to Marco Trevisan.

[1]: f401f399a8
This commit is contained in:
Iain Lane
2021-03-02 13:15:50 +00:00
parent 098bd29fe7
commit 373e46c2b2
2 changed files with 20 additions and 4 deletions

View File

@@ -12,6 +12,21 @@ test_c_args = [
'-UG_DISABLE_ASSERT',
]
# workaround for https://github.com/mesonbuild/meson/issues/6880
if build_machine.system() == 'linux'
libutil_name = 'libutil'
libutil = run_command('sh', '-c',
'''ldconfig -p | grep -o "[[:space:]]@0@\.so\(\.[0-9]\+\)\?\b"'''
.format(libutil_name)).stdout().strip().split('\n')
if libutil.length() > 0
message('Found libutil as @0@'.format(libutil[0]))
test_c_args += '-DLIBUTIL_SONAME="@0@"'.format(libutil[0])
else
warning('libutil not found')
endif # libutil.length() > 0
endif # build_machine.system() == 'linux'
if host_machine.system() == 'windows'
common_gio_tests_deps += [iphlpapi_dep, winsock2, cc.find_library ('secur32')]
endif