Browse Source

meson: fix clock_gettime detection

Alexandre Janniaux 5 years ago
parent
commit
efc2e4f35f
1 changed files with 12 additions and 5 deletions
  1. 12 5
      meson.build

+ 12 - 5
meson.build

@@ -91,11 +91,18 @@ else
   compat_sources += 'compat/strndup.c'
 endif
 
-#if cc.has_function('clock_gettime', prefix: '#include <time.h>', args: test_args)
-#  conf_data.set('HAVE_CLOCK_GETTIME', 1)
-#else
-#  compat_sources += 'compat/clock_gettime.c'
-#endif
+if cc.has_function('clock_gettime', prefix: '#include <time.h>',
+                   dependencies: dep_thread)
+  conf_data.set('HAVE_CLOCK_GETTIME', 1)
+else
+  dep_rt = cc.find_library('rt', required: false)
+  if cc.has_function('clock_gettime', prefix: '#include <time.h>',
+                     dependencies: [dep_rt, dep_thread])
+    conf_data.set('HAVE_CLOCK_GETTIME', 1)
+  else
+    compat_sources += 'compat/clock_gettime.c'
+  endif
+endif
 
 if cc.has_function('pipe')
   conf_data.set('HAVE_PIPE', 1)