+if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9)
+ message(FATAL_ERROR "Require at least gcc-4.9")
+endif(CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9)
+
+INCLUDE(FindPkgConfig)
+
+ADD_DEFINITIONS(-DBINDING_INSTALL_DIR="${binding_install_dir}")
+# Always add INFER_EXTENSION (more details in afb-hreq.c)
+ADD_DEFINITIONS(-DINFER_EXTENSION)
+
+CHECK_INCLUDE_FILES(magic.h HAVE_MAGIC_H)
+CHECK_LIBRARY_EXISTS(magic magic_load "" HAVE_LIBMAGIC_SO)
+IF(HAVE_MAGIC_H)
+ IF(HAVE_LIBMAGIC_SO)
+ SET(HAVE_LIBMAGIC "1")
+ ENDIF(HAVE_LIBMAGIC_SO)
+ENDIF(HAVE_MAGIC_H)
+
+IF(NOT HAVE_LIBMAGIC)
+ MESSAGE(FATAL_ERROR "\"magic.h\" or \"libmagic.so\" missing.
+ Please install the \"file-devel\" or \"libmagic-dev\" package !")
+ENDIF(NOT HAVE_LIBMAGIC)
+ADD_DEFINITIONS(-DUSE_MAGIC_MIME_TYPE)
+
+PKG_CHECK_MODULES(libsystemd REQUIRED libsystemd>=222)
+PKG_CHECK_MODULES(libmicrohttpd REQUIRED libmicrohttpd>=0.9.48)
+PKG_CHECK_MODULES(openssl REQUIRED openssl)
+PKG_CHECK_MODULES(uuid REQUIRED uuid)
+
+INCLUDE_DIRECTORIES(
+ ${include_dirs}
+ ${libsystemd_INCLUDE_DIRS}
+ ${libmicrohttpd_INCLUDE_DIRS}
+ ${uuid_INCLUDE_DIRS}
+ ${openssl_INCLUDE_DIRS}
+)
+
+ADD_LIBRARY(afb-lib STATIC