From 74182eb605bf0e45b777cb8b942f5263877c7e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Yhuel?= Date: Thu, 2 Apr 2020 18:25:54 +0200 Subject: [PATCH] meson: link with -lrt if needed for clock_gettime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is already done in autotools, and fixes the build with glibc < 2.17. Signed-off-by: Loïc Yhuel --- meson.build | 8 ++++++++ src/meson.build | 5 +++-- tests/meson.build | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 8d7b4a9..fb0d01d 100644 --- a/meson.build +++ b/meson.build @@ -56,6 +56,14 @@ if get_option('libraries') error('@0@ is needed to compile Wayland libraries'.format(d['symbol'])) endif endforeach + + rt_dep = [] + if not cc.has_function('clock_gettime', prefix: '#include ') + rt_dep = cc.find_library('rt') + if not cc.has_function('clock_gettime', prefix: '#include ', dependencies: rt_dep) + error('clock_gettime not found') + endif + endif endif scanner_deps = [ dependency('expat') ] diff --git a/src/meson.build b/src/meson.build index 2d1485c..d91c503 100644 --- a/src/meson.build +++ b/src/meson.build @@ -77,7 +77,7 @@ if get_option('libraries') 'connection.c', 'wayland-os.c' ], - dependencies: [ ffi_dep, ] + dependencies: [ ffi_dep, rt_dep ] ) wayland_private_dep = declare_dependency( @@ -155,7 +155,8 @@ if get_option('libraries') wayland_private_dep, wayland_util_dep, mathlib_dep, - threads_dep + threads_dep, + rt_dep ], include_directories: root_inc, install: true diff --git a/tests/meson.build b/tests/meson.build index 224f48d..a32ac50 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -54,7 +54,7 @@ benchmark( executable( 'fixed-benchmark', 'fixed-benchmark.c', - dependencies: test_runner_dep + dependencies: [ test_runner_dep, rt_dep ] ) )