improves the build system
[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_VERSION "0.4")
10
11 INCLUDE(FindPkgConfig)
12 INCLUDE(CheckIncludeFiles)
13 INCLUDE(CheckLibraryExists)
14 INCLUDE(GNUInstallDirs)
15
16 ###########################################################################
17
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)
27
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")
32
33 ###########################################################################
34
35 IF(CMAKE_BUILD_TYPE MATCHES Debug)
36   CHECK_LIBRARY_EXISTS(efence malloc "" HAVE_LIBEFENCE)
37   IF(HAVE_LIBEFENCE)
38     MESSAGE(STATUS "Linking with ElectricFence for debugging purposes...")
39     SET(libefence_LIBRARIES "-lefence")
40   ENDIF(HAVE_LIBEFENCE)
41 ENDIF(CMAKE_BUILD_TYPE MATCHES Debug)
42
43 PKG_CHECK_MODULES(json-c REQUIRED json-c)
44
45 INCLUDE(FindThreads)
46 FIND_PACKAGE(Threads)
47
48 SET(include_dirs
49         ${INCLUDE_DIRS}
50         ${CMAKE_SOURCE_DIR}/include
51         ${json-c_INCLUDE_DIRS}
52 )
53
54 SET(link_libraries
55         ${libefence_LIBRARIES}
56         ${CMAKE_THREAD_LIBS_INIT}
57         ${json-c_LIBRARIES}
58 )
59
60 SET(plugin_install_dir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/afb)
61
62 ADD_DEFINITIONS(-DPLUGIN_INSTALL_DIR="${plugin_install_dir}")
63
64 ADD_SUBDIRECTORY(src)
65 ADD_SUBDIRECTORY(include)
66 ADD_SUBDIRECTORY(plugins)
67