summaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2018-06-05 11:26:56 +0200
committerFrediano Ziglio <fziglio@redhat.com>2018-06-05 14:09:50 +0100
commite98f8a430f7e2fd64dab74f9b9a85ee2dfa1b92f (patch)
treecb47e1a1617e7a188bbec717d6364b175ae860a6 /meson.build
parent349a74d7c272fdba04533760779dc9d0c2f7f073 (diff)
build: Ensure we link with -lm if needed
lines.c uses hypot(), which is found in libm on some systems. This means we are currently relying on getting -lm indirectly through some other means, as otherwise linking any binary with spice-common would fail. Signed-off-by: Christophe Fergeau <cfergeau@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build10
1 files changed, 10 insertions, 0 deletions
diff --git a/meson.build b/meson.build
index de777db..4dd4610 100644
--- a/meson.build
+++ b/meson.build
@@ -87,6 +87,16 @@ foreach func : functions
endif
endforeach
+# check for hypot function
+#
+# Include math.h header to avoid problems with builtins.
+# In some systems the function is in libm.
+if not compiler.has_function('hypot', prefix : '#include <math.h>')
+ libm = compiler.find_library('m', required : false)
+ if compiler.has_function('hypot', prefix : '#include <math.h>', dependencies : libm)
+ spice_common_deps += libm
+ endif
+endif
#
# check for mandatory dependencies