improves compatibility with yocto
[src/app-framework-binder.git] / CMakeLists.txt
1 PROJECT(afb-daemon C)
2
3 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
4 SET(CMAKE_BUILD_TYPE, Debug)
5 SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
6
7 SET(PROJECT_NAME "AFB Daemon")
8 SET(PROJECT_PRETTY_NAME "Application Framework Binder Daemon")
9 SET(PROJECT_DESCRIPTION "Secured binder of API for clients of the Application framework")
10 SET(PROJECT_VERSION "0.5")
11 SET(PROJECT_URL "https://github.com/iotbzh/afb-daemon")
12
13 INCLUDE(FindPkgConfig)
14 INCLUDE(CheckIncludeFiles)
15 INCLUDE(CheckLibraryExists)
16 INCLUDE(GNUInstallDirs)
17
18 ###########################################################################
19
20 link_libraries(-Wl,--as-needed -Wl,--gc-sections)
21
22 add_compile_options(-Wall -Wextra -Wconversion)
23 add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care?
24 add_compile_options(-Wno-sign-compare -Wno-sign-conversion)
25 add_compile_options(-Werror=maybe-uninitialized)
26 add_compile_options(-Werror=implicit-function-declaration)
27 add_compile_options(-ffunction-sections -fdata-sections)
28 add_compile_options(-Wl,--as-needed -Wl,--gc-sections)
29 add_compile_options(-fPIC)
30 add_compile_options(-g)
31
32 set(CMAKE_C_FLAGS_PROFILING    "-g -O2 -pg -Wp,-U_FORTIFY_SOURCE")
33 set(CMAKE_C_FLAGS_DEBUG        "-g -O2 -ggdb -Wp,-U_FORTIFY_SOURCE")
34 set(CMAKE_C_FLAGS_RELEASE      "-g -O2")
35 set(CMAKE_C_FLAGS_CCOV         "-g -O2 --coverage")
36
37 ###########################################################################
38
39 IF(CMAKE_BUILD_TYPE MATCHES Debug)
40   CHECK_LIBRARY_EXISTS(efence malloc "" HAVE_LIBEFENCE)
41   IF(HAVE_LIBEFENCE)
42     MESSAGE(STATUS "Linking with ElectricFence for debugging purposes...")
43     SET(libefence_LIBRARIES "-lefence")
44   ENDIF(HAVE_LIBEFENCE)
45 ENDIF(CMAKE_BUILD_TYPE MATCHES Debug)
46
47 PKG_CHECK_MODULES(json-c REQUIRED json-c)
48
49 INCLUDE(FindThreads)
50 FIND_PACKAGE(Threads)
51
52 SET(include_dirs
53         ${INCLUDE_DIRS}
54         ${CMAKE_SOURCE_DIR}/include
55         ${json-c_INCLUDE_DIRS}
56         )
57
58 SET(link_libraries
59         ${libefence_LIBRARIES}
60         ${CMAKE_THREAD_LIBS_INIT}
61         ${json-c_LIBRARIES}
62         )
63
64 SET(plugin_install_dir ${CMAKE_INSTALL_FULL_LIBDIR}/afb)
65
66 ADD_DEFINITIONS(-DPLUGIN_INSTALL_DIR="${plugin_install_dir}")
67
68 ADD_SUBDIRECTORY(src)
69 ADD_SUBDIRECTORY(include)
70 ADD_SUBDIRECTORY(plugins)
71
72 ############################################################
73 # installs the pkgconfig file
74 CONFIGURE_FILE(afb-daemon.pc.in afb-daemon.pc @ONLY)
75
76 INSTALL(FILES
77     ${CMAKE_CURRENT_BINARY_DIR}/afb-daemon.pc
78     DESTINATION
79     ${CMAKE_INSTALL_LIBDIR}/pkgconfig
80     )
81