3 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
4 SET(CMAKE_BUILD_TYPE, Debug)
5 SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
7 SET(PROJECT_NAME "AFB Daemon")
8 SET(PROJECT_PRETTY_NAME "Application Framework Binder Daemon")
9 SET(PROJECT_VERSION "0.3")
11 INCLUDE(FindPkgConfig)
12 INCLUDE(CheckIncludeFiles)
13 INCLUDE(CheckLibraryExists)
14 INCLUDE(GNUInstallDirs)
16 ###########################################################################
18 add_compile_options(-Wall -Wextra -Wconversion)
19 add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care?
20 add_compile_options(-Wno-sign-compare -Wno-sign-conversion)
21 add_compile_options(-Werror=maybe-uninitialized)
22 add_compile_options(-Werror=implicit-function-declaration)
23 add_compile_options(-ffunction-sections -fdata-sections)
24 add_compile_options(-Wl,--gc-sections)
25 add_compile_options(-fPIC)
26 add_compile_options(-g)
28 set(CMAKE_C_FLAGS_PROFILING "-g -O2 -pg -Wp,-U_FORTIFY_SOURCE")
29 set(CMAKE_C_FLAGS_DEBUG "-g -O2 -ggdb -Wp,-U_FORTIFY_SOURCE")
30 set(CMAKE_C_FLAGS_RELEASE "-g -O2")
31 set(CMAKE_C_FLAGS_CCOV "-g -O2 --coverage")
33 ###########################################################################
36 CHECK_INCLUDE_FILES(magic.h HAVE_MAGIC_H)
37 CHECK_LIBRARY_EXISTS(magic magic_load "" HAVE_LIBMAGIC_SO)
40 SET(HAVE_LIBMAGIC "1")
41 ENDIF(HAVE_LIBMAGIC_SO)
44 MESSAGE(FATAL_ERROR "\"magic.h\" or \"libmagic.so\" missing.
45 Please install the \"file-devel\" or \"libmagic-dev\" package !")
46 ENDIF(NOT HAVE_LIBMAGIC)
48 IF(CMAKE_BUILD_TYPE MATCHES Debug)
49 CHECK_LIBRARY_EXISTS(efence malloc "" HAVE_LIBEFENCE)
51 MESSAGE(STATUS "Linking with ElectricFence for debugging purposes...")
52 SET(libefence_LIBRARIES "-lefence")
54 ENDIF(CMAKE_BUILD_TYPE MATCHES Debug)
56 INCLUDE(FindPkgConfig)
57 PKG_CHECK_MODULES(libsystemd REQUIRED libsystemd>=222)
58 PKG_CHECK_MODULES(json-c REQUIRED json-c)
59 PKG_CHECK_MODULES(libmicrohttpd REQUIRED libmicrohttpd>=0.9.48)
60 PKG_CHECK_MODULES(openssl REQUIRED openssl)
61 PKG_CHECK_MODULES(uuid REQUIRED uuid)
62 # Optional plugin dependencies
63 PKG_CHECK_MODULES(alsa alsa)
64 PKG_CHECK_MODULES(pulseaudio libpulse libpulse-simple)
65 PKG_CHECK_MODULES(librtlsdr librtlsdr>=0.5.0)
66 PKG_CHECK_MODULES(gupnp gupnp-1.0 gupnp-av-1.0 gssdp-1.0 gobject-2.0 gio-2.0)
69 MESSAGE(STATUS "ALSA found ; will compile Audio plugin... (PLUGIN)")
71 MESSAGE(STATUS "PulseAudio found ; Audio plugin will have PulseAudio support")
72 ADD_DEFINITIONS(-DHAVE_PULSE=1)
73 ENDIF(pulseaudio_FOUND)
77 MESSAGE(STATUS "librtlsdr found ; will compile Radio plugin... (PLUGIN)")
78 ENDIF(librtlsdr_FOUND)
81 MESSAGE(STATUS "gupnp found ; will compile Media plugin... (PLUGIN)")
89 ${CMAKE_SOURCE_DIR}/include
90 ${libsystemd_INCLUDE_DIRS}
91 ${json-c_INCLUDE_DIRS}
92 ${libmicrohttpd_INCLUDE_DIRS}
95 ${pulseaudio_INCLUDE_DIRS}
96 ${librtlsdr_INCLUDE_DIRS}
98 ${openssl_INCLUDE_DIRS}
102 ${libsystemd_LIBRARIES}
104 ${libmicrohttpd_LIBRARIES}
107 ${pulseaudio_LIBRARIES}
108 ${librtlsdr_LIBRARIES}
110 ${CMAKE_THREAD_LIBS_INIT}
111 # ${libefence_LIBRARIES}
119 SET(plugin_install_dir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/afb)
121 ADD_DEFINITIONS(-DPLUGIN_INSTALL_DIR="${plugin_install_dir}")
123 ADD_SUBDIRECTORY(src)
124 ADD_SUBDIRECTORY(plugins)
126 ADD_EXECUTABLE(afb-daemon $<TARGET_OBJECTS:src>)
127 INCLUDE_DIRECTORIES(${include_dirs})
128 TARGET_LINK_LIBRARIES(afb-daemon ${link_libraries})
130 INSTALL(TARGETS afb-daemon
131 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})