From 89dbabff65a39dfb0d9ad036516d5b96c37739de Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 12 Mar 2018 13:27:38 +0800 Subject: [PATCH] configure.ac/CMake: Check for round() and stdbool.h Not all the compilers that HarfBuzz is buildable on supports round() and has the header stdbool.h, so we check for them and define HAVE_ROUND and HAVE_STDBOOL_H repsectively in our CFLAGS so that we include them only when they are found, or use fallback implementations when necessary. Also include FindPythonInterp earlier as we need PYTHON_EXECUTABLE to be set for running the tests. --- CMakeLists.txt | 12 ++++++++++-- configure.ac | 9 ++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index defd5d6..62e7945 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,8 @@ include_directories(AFTER add_definitions(-DHAVE_OT) add_definitions(-DHAVE_FALLBACK) +# We need PYTHON_EXECUTABLE to be set for running the tests... +include (FindPythonInterp) ## Functions and headers include (CheckFunctionExists) @@ -103,7 +105,10 @@ macro (check_funcs) # Similar to AC_CHECK_FUNCS of autotools endif () endforeach () endmacro () -check_funcs(atexit mprotect sysconf getpagesize mmap isatty newlocale strtod_l) +if (UNIX) + list(APPEND CMAKE_REQUIRED_LIBRARIES m) +endif () +check_funcs(atexit mprotect sysconf getpagesize mmap isatty newlocale strtod_l round) check_include_file(unistd.h HAVE_UNISTD_H) if (${HAVE_UNISTD_H}) add_definitions(-DHAVE_UNISTD_H) @@ -116,6 +121,10 @@ check_include_file(xlocale.h HAVE_XLOCALE_H) if (${HAVE_XLOCALE_H}) add_definitions(-DHAVE_XLOCALE_H) endif () +check_include_file(stdbool.h HAVE_STDBOOL_H) +if (${HAVE_STDBOOL_H}) + add_definitions(-DHAVE_STDBOOL_H) +endif () if (MSVC) @@ -385,7 +394,6 @@ if (WIN32 AND HB_HAVE_DIRECTWRITE) endif () if (HB_HAVE_GOBJECT) - include (FindPythonInterp) include (FindPerl) # Use the hints from glib-2.0.pc to find glib-mkenums diff --git a/configure.ac b/configure.ac index 1fb8a10..031be4a 100644 --- a/configure.ac +++ b/configure.ac @@ -78,8 +78,15 @@ GTK_DOC_CHECK([1.15],[--flavour no-tmpl]) ]) # Functions, and headers + AC_CHECK_FUNCS(atexit mprotect sysconf getpagesize mmap isatty newlocale strtod_l setlinebuf) -AC_CHECK_HEADERS(unistd.h sys/mman.h xlocale.h) + +save_libs="$LIBS" +LIBS="$LIBS -lm" +AC_CHECK_FUNCS([round], ,[AC_CHECK_DECLS([round], , ,[#include ])]) +LIBS="$save_libs" + +AC_CHECK_HEADERS(unistd.h sys/mman.h xlocale.h stdbool.h) # Compiler flags AC_CANONICAL_HOST -- 2.7.4