-INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(json-c REQUIRED json-c)
-PKG_CHECK_MODULES(libmicrohttpd REQUIRED libmicrohttpd)
-PKG_CHECK_MODULES(uuid REQUIRED uuid)
-PKG_CHECK_MODULES(dbus REQUIRED dbus-1)
-# Optional plugin dependencies
-PKG_CHECK_MODULES(alsa alsa)
-PKG_CHECK_MODULES(pulseaudio libpulse libpulse-simple)
-PKG_CHECK_MODULES(librtlsdr librtlsdr>=0.5.0)
-
-IF(alsa_FOUND)
- MESSAGE(STATUS "ALSA found ; will compile Audio plugin... (PLUGIN)")
- IF(pulseaudio_FOUND)
- MESSAGE(STATUS "PulseAudio found ; Audio plugin will have PulseAudio support")
- ADD_DEFINITIONS(-DHAVE_PULSE=1)
- ENDIF(pulseaudio_FOUND)
-ENDIF(alsa_FOUND)
-
-IF(librtlsdr_FOUND)
- MESSAGE(STATUS "librtlsdr found ; will compile Radio plugin... (PLUGIN)")
-ENDIF(librtlsdr_FOUND)
+############################################################################
+
+option(WITH_SIG_MONITOR_DUMPSTACK "Activate dump stack on error" ON)
+option(WITH_SIG_MONITOR_SIGNALS "Activate handling of signals" ON)
+option(WITH_SIG_MONITOR_FOR_CALL "Activate monitoring of calls" ON)
+option(WITH_SIG_MONITOR_TIMERS "Activate monitoring of call expiration" ON)
+option(WITH_AFB_HOOK "Include hooking" ON)
+option(WITH_AFB_TRACE "Include monitoring trace" ON)
+option(WITH_SUPERVISOR "Activates installation of supervisor" OFF)
+option(WITH_MONITORING "Activates installation of monitoring" OFF)
+option(WITH_DBUS_TRANSPARENCY "Allows API transparency over DBUS" OFF)
+option(WITH_LEGACY_BINDING_V1 "Includes the legacy Binding API version 1" OFF)
+option(WITH_LEGACY_BINDING_V2 "Includes the legacy Binding API version 2" ON)
+option(WITH_LEGACY_BINDING_VDYN "Includes the legacy Binding API version dynamic" OFF)
+option(WITH_DYNAMIC_BINDING "Allow to load dynamic bindings (shared libraries)" ON)
+option(WITH_LIBMICROHTTPD "Activates HTTP server through LIBMICROHTTPD" ON)
+option(WITH_FNMATCH "Use fnmatch where possible" ON)
+option(WITH_L4VSOCK "Activates L4RE support of VIRTIO-SOCKS" OFF)
+
+############################################################################
+# legacy options
+
+option(INCLUDE_SUPERVISOR "Activates installation of supervisor" OFF)
+option(INCLUDE_MONITORING "Activates installation of monitoring" OFF)
+option(INCLUDE_DBUS_TRANSPARENCY "Allows API transparency over DBUS" OFF)
+option(INCLUDE_LEGACY_BINDING_V1 "Includes the legacy Binding API version 1" OFF)
+option(INCLUDE_LEGACY_BINDING_VDYN "Includes the legacy Binding API version dynamic" OFF)
+
+if(INCLUDE_SUPERVISOR)
+ set(WITH_SUPERVISOR ON)
+endif()
+if(INCLUDE_MONITORING)
+ set(WITH_MONITORING ON)
+endif()
+if(INCLUDE_DBUS_TRANSPARENCY)
+ set(WITH_DBUS_TRANSPARENCY ON)
+endif()
+if(INCLUDE_LEGACY_BINDING_V1)
+ set(WITH_LEGACY_BINDING_V1 ON)
+endif()
+if(INCLUDE_LEGACY_BINDING_VDYN)
+ set(WITH_LEGACY_BINDING_VDYN ON)
+endif()
+
+###########################################################################
+
+set(AFS_SUPERVISION_SOCKET "@urn:AGL:afs:supervision:socket" CACHE STRING "Internal socket for supervision")
+set(AFS_SUPERVISOR_PORT 1619 CACHE STRING "Port of service for the supervisor")
+set(AFS_SUPERVISOR_TOKEN HELLO CACHE STRING "Secret token for the supervisor")
+set(UNITDIR_SYSTEM ${CMAKE_INSTALL_LIBDIR}/systemd/system CACHE STRING "Path to systemd system unit files")
+
+###########################################################################
+
+link_libraries(-Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined)
+
+add_compile_options(-Wall -Wextra -Wconversion)
+add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care?
+add_compile_options(-Wno-sign-compare -Wno-sign-conversion)
+add_compile_options(-Werror=maybe-uninitialized)
+add_compile_options(-Werror=implicit-function-declaration)
+add_compile_options(-ffunction-sections -fdata-sections)
+add_compile_options(-fPIC)
+add_compile_options(-g)
+set (CMAKE_CXX_STANDARD 14)
+
+set(CMAKE_C_FLAGS_PROFILING "-g -O2 -pg -Wp,-U_FORTIFY_SOURCE")
+set(CMAKE_C_FLAGS_DEBUG "-g -ggdb -Wp,-U_FORTIFY_SOURCE")
+set(CMAKE_C_FLAGS_RELEASE "-g -O2")
+set(CMAKE_C_FLAGS_CCOV "-g -O2 --coverage")
+
+###########################################################################
+
+if(ONLY_DEVTOOLS)
+ set(WITH_LIBMICROHTTPD OFF)
+ set(WITH_SYSTEMD OFF)
+endif(ONLY_DEVTOOLS)
+
+if(NOT WITH_LIBMICROHTTPD)
+ set(WITH_MONITORING OFF)
+endif()
+###########################################################################