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.
This commit is contained in:
Chun-wei Fan 2018-03-12 13:27:38 +08:00
parent 28f25f32fc
commit 89dbabff65
2 changed files with 18 additions and 3 deletions

View File

@ -90,6 +90,8 @@ include_directories(AFTER
add_definitions(-DHAVE_OT) add_definitions(-DHAVE_OT)
add_definitions(-DHAVE_FALLBACK) add_definitions(-DHAVE_FALLBACK)
# We need PYTHON_EXECUTABLE to be set for running the tests...
include (FindPythonInterp)
## Functions and headers ## Functions and headers
include (CheckFunctionExists) include (CheckFunctionExists)
@ -103,7 +105,10 @@ macro (check_funcs) # Similar to AC_CHECK_FUNCS of autotools
endif () endif ()
endforeach () endforeach ()
endmacro () 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) check_include_file(unistd.h HAVE_UNISTD_H)
if (${HAVE_UNISTD_H}) if (${HAVE_UNISTD_H})
add_definitions(-DHAVE_UNISTD_H) add_definitions(-DHAVE_UNISTD_H)
@ -116,6 +121,10 @@ check_include_file(xlocale.h HAVE_XLOCALE_H)
if (${HAVE_XLOCALE_H}) if (${HAVE_XLOCALE_H})
add_definitions(-DHAVE_XLOCALE_H) add_definitions(-DHAVE_XLOCALE_H)
endif () endif ()
check_include_file(stdbool.h HAVE_STDBOOL_H)
if (${HAVE_STDBOOL_H})
add_definitions(-DHAVE_STDBOOL_H)
endif ()
if (MSVC) if (MSVC)
@ -385,7 +394,6 @@ if (WIN32 AND HB_HAVE_DIRECTWRITE)
endif () endif ()
if (HB_HAVE_GOBJECT) if (HB_HAVE_GOBJECT)
include (FindPythonInterp)
include (FindPerl) include (FindPerl)
# Use the hints from glib-2.0.pc to find glib-mkenums # Use the hints from glib-2.0.pc to find glib-mkenums

View File

@ -78,8 +78,15 @@ GTK_DOC_CHECK([1.15],[--flavour no-tmpl])
]) ])
# Functions, and headers # Functions, and headers
AC_CHECK_FUNCS(atexit mprotect sysconf getpagesize mmap isatty newlocale strtod_l setlinebuf) 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 <math.h>])])
LIBS="$save_libs"
AC_CHECK_HEADERS(unistd.h sys/mman.h xlocale.h stdbool.h)
# Compiler flags # Compiler flags
AC_CANONICAL_HOST AC_CANONICAL_HOST