summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Rabaud <vrabaud@google.com>2018-09-03 10:34:20 +0200
committerVincent Rabaud <vrabaud@google.com>2018-09-03 14:35:50 +0000
commitd71df4e2eea7115ea13d8ea981203bd817625501 (patch)
tree58148fadf3b550469a604d22902202732930d529
parentde08d72741c696f8f2988f2db3f02c773e0fb6f5 (diff)
downloadlibwebp-d71df4e2eea7115ea13d8ea981203bd817625501.tar.gz
Fix math library finding in CMake.
BUG=webp:396 Change-Id: I8ca35573c242cba24f1e82997b4fb289a48a3005
-rw-r--r--cmake/deps.cmake17
1 files changed, 13 insertions, 4 deletions
diff --git a/cmake/deps.cmake b/cmake/deps.cmake
index 11b44ef3..4b008118 100644
--- a/cmake/deps.cmake
+++ b/cmake/deps.cmake
@@ -54,10 +54,19 @@ set(LT_OBJDIR ".libs/")
find_package(OpenGL)
set(WEBP_HAVE_GL ${OPENGL_FOUND})
-# Find the standard C math library.
-find_library(MATH_LIBRARY NAMES m)
-if(MATH_LIBRARY)
- list(APPEND WEBP_DEP_LIBRARIES ${MATH_LIBRARY})
+# Check if we need to link to the C math library.
+# We do not look for it as it is not found when
+# cross-compiling, while it is here.
+check_c_source_compiles("
+ #include <cmath>
+ int main(void) {
+ return std::pow(2, 2.5);
+ }
+ "
+ HAVE_MATH_LIBRARY
+)
+if(NOT HAVE_MATH_LIBRARY)
+ list(APPEND WEBP_DEP_LIBRARIES m)
endif()
# Find the standard image libraries.