diff --git a/CMakeLists.txt b/CMakeLists.txt
index adaa91ad856b3f64bf18a1619149d310fb8f82d1..bf9110af76afe83ed3f2ed89d0d55ec29f8cf486 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -338,6 +338,8 @@ if(ENABLE_BLAS_LAPACK)
         list(APPEND EXTERNAL_LIBRARIES ${LAPACK_LIB})
         set_config_option(HAVE_LAPACK "Lapack")
       endif(LAPACK_LIB)
+      # for isnan/isinf
+      add_definitions(-D_GLIBCXX_USE_C99_MATH=1)
     endif(ENABLE_BUILD_ANDROID)
 
     if(NOT HAVE_BLAS OR NOT HAVE_LAPACK)