[cmake] Add autotools like feature testing (#683)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ebbfbe3..b61d660 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,6 +39,7 @@
 option(HB_HAVE_ICU "Enable icu unicode functions" OFF)
 if (APPLE)
   option(HB_HAVE_CORETEXT "Enable CoreText shaper backend on macOS" ON)
+  set (CMAKE_MACOSX_RPATH ON)
 endif ()
 if (WIN32)
   option(HB_HAVE_UNISCRIBE "Enable Uniscribe shaper backend on Windows" OFF)
@@ -88,12 +89,15 @@
 add_definitions(-DHAVE_OT)
 add_definitions(-DHAVE_FALLBACK)
 
-if (BUILD_SHARED_LIBS)
-  add_definitions(-DHAVE_ATEXIT)
-  if (APPLE)
-    set (CMAKE_MACOSX_RPATH ON)
-  endif ()
-endif ()
+include(CheckFunctionExists)
+check_function_exists(atexit HAVE_ATEXIT)
+check_function_exists(mprotect HAVE_MPROTECT)
+check_function_exists(sysconf HAVE_SYSCONF)
+check_function_exists(getpagesize HAVE_GETPAGESIZE)
+check_function_exists(mmap HAVE_MMAP)
+check_function_exists(isatty HAVE_ISATTY)
+check_function_exists(newlocale HAVE_NEWLOCALE)
+check_function_exists(strtod_l HAVE_STRTOD_L)
 
 if (MSVC)
   add_definitions(-wd4244 -wd4267 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
@@ -244,6 +248,12 @@
 
   list(APPEND project_sources ${PROJECT_SOURCE_DIR}/src/hb-ft.cc)
   list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-ft.h)
+
+  set (CMAKE_REQUIRED_INCLUDES ${FREETYPE_INCLUDE_DIRS})
+  set (CMAKE_REQUIRED_LIBRARIES ${FREETYPE_LIBRARIES})
+  check_function_exists(FT_Get_Var_Blend_Coordinates HAVE_FT_GET_VAR_BLEND_COORDINATES)
+  check_function_exists(FT_Set_Var_Blend_Coordinates HAVE_FT_SET_VAR_BLEND_COORDINATES)
+  check_function_exists(FT_Done_MM_Var HAVE_FT_DONE_MM_VAR)
 endif ()
 
 if (HB_HAVE_GRAPHITE2)