diff options
| author | Charles Karney <charles@karney.com> | 2017-08-13 09:50:34 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-13 09:50:34 -0400 |
| commit | c4894645685dcd37bcb06e24395333e1a5e04e1d (patch) | |
| tree | ef17eab0d5ff7fc655eb94d6ed6df58fe3be89b3 | |
| parent | 945e247ff1ef787630ebe21ee7b9243e151fe9bb (diff) | |
| parent | 3b36c73c2a95e3fe2db86cd34f19c29c993a3098 (diff) | |
| download | PROJ-c4894645685dcd37bcb06e24395333e1a5e04e1d.tar.gz PROJ-c4894645685dcd37bcb06e24395333e1a5e04e1d.zip | |
Merge pull request #555 from cffk/c99-math-test
Add tests for C99 math functions, hypot, atanh, cbrt, etc.
-DHAVE_C99_MATH=1 is provided if these functions are available. This
will be used by the next release of geodesic.c.
| -rw-r--r-- | CMakeLists.txt | 22 | ||||
| -rw-r--r-- | configure.ac | 14 |
2 files changed, 36 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index eb0cbcba..702eafaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,28 @@ if (HAVE_PTHREAD_MUTEX_RECURSIVE_DEFN) add_definitions(-DHAVE_PTHREAD_MUTEX_RECURSIVE=1) endif() +include (CheckCSourceCompiles) +if (MSVC) + set (CMAKE_REQUIRED_FLAGS "${CMAKE_C_FLAGS} /WX") +else () + set (CMAKE_REQUIRED_LIBRARIES m) + set (CMAKE_REQUIRED_FLAGS "${CMAKE_C_FLAGS} -Werror") +endif () +# Check whether the C99 math function: hypot, atanh, etc. are available. +check_c_source_compiles ( + "#include <math.h> +int main() { + int q; + return (int)(hypot(3.0, 4.0) + atanh(0.8) + cbrt(8.0) + + remquo(100.0, 90.0, &q) + + remainder(100.0, 90.0) + copysigna(1.0, -0.0)); +}\n" C99_MATH) +if (C99_MATH) + add_definitions (-DHAVE_C99_MATH=1) +else () + add_definitions (-DHAVE_C99_MATH=0) +endif () + boost_report_value(PROJ_PLATFORM_NAME) boost_report_value(PROJ_COMPILER_NAME) diff --git a/configure.ac b/configure.ac index 68df28ec..e99389ee 100644 --- a/configure.ac +++ b/configure.ac @@ -29,6 +29,20 @@ CFLAGS="$save_CFLAGS" dnl We check for headers AC_HEADER_STDC +dnl Check for C99 math functions +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wall -Werror" +AC_MSG_CHECKING([for C99 math functions]) +AC_LINK_IFELSE([AC_LANG_PROGRAM( + [#include <math.h>], + [int q; + return (int)(hypot(3.0, 4.0) + atanh(0.8) + cbrt(8.0) + + remquo(100.0, 90.0, &q) + + remainder(100.0, 90.0) + copysign(1.0, -0.0));])], + [AC_MSG_RESULT([yes]);C99_MATH="-DHAVE_C99_MATH=1"], + [AC_MSG_RESULT([no]);C99_MATH="-DHAVE_C99_MATH=0"]) +CFLAGS="$save_CFLAGS $C99_MATH" + AC_CHECK_FUNC(localeconv, [AC_DEFINE(HAVE_LOCALECONV,1,[Define to 1 if you have localeconv])]) dnl --------------------------------------------------------------------------- |
