[glib: 1/2] Meson: Add check for strlcpy/strlcat



commit 5ebcfdf44703c4c41d4bd4ff33377a03b4bbddf9
Author: Xavier Claessens <xavier claessens collabora com>
Date:   Thu Jun 14 14:00:43 2018 -0400

    Meson: Add check for strlcpy/strlcat
    
    I don't know why it runs the code in autotools instead of only checking
    if it links, but let's copy the same logic for now.

 meson.build | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
---
diff --git a/meson.build b/meson.build
index 641a16008..27c63a095 100644
--- a/meson.build
+++ b/meson.build
@@ -1761,6 +1761,24 @@ if host_system != 'windows' and get_option('xattr')
   endif
 endif
 
+if cc_can_run
+  rres = cc.run('''#include <stdlib.h>
+                   #include <string.h>
+                   int main() {
+                     char p[10];
+                     (void) strlcpy (p, "hi", 10);
+                     if (strlcat (p, "bye", 0) != 3)
+                       return 1;
+                     return 0;
+                   }''',
+                name : 'OpenBSD strlcpy/strlcat')
+  if rres.compiled() and rres.returncode() == 0
+    glib_conf.set('HAVE_STRLCPY', 1)
+  endif
+elif meson.get_cross_property('have_strlcpy', false)
+  glib_conf.set('HAVE_STRLCPY', 1)
+endif
+
 python = import('python3').find_python()
 
 # Determine which user environment-dependent files that we want to install


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]