1 ###########################################################################
2 # Copyright 2015, 2016, 2017 IoT.bzh
4 # author: José Bollo <jose.bollo@iot.bzh>
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 ###########################################################################
21 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
22 SET(CMAKE_BUILD_TYPE Debug)
23 SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
25 SET(PROJECT_NAME "AFB Daemon")
26 SET(PROJECT_PRETTY_NAME "Application Framework Binder Daemon")
27 SET(PROJECT_DESCRIPTION "Secured binder of API for clients of the Application framework")
28 SET(PROJECT_VERSION "1.0")
29 SET(PROJECT_URL "https://github.com/iotbzh/afb-daemon")
31 SET(LIBAFBWSC_VERSION "1.0")
32 SET(LIBAFBWSC_SOVERSION "1")
34 INCLUDE(FindPkgConfig)
35 INCLUDE(CheckIncludeFiles)
36 INCLUDE(CheckLibraryExists)
37 INCLUDE(GNUInstallDirs)
40 ###########################################################################
42 set(AGL_DEVEL OFF CACHE BOOL "Activates developping features")
43 set(INCLUDE_MONITORING OFF CACHE BOOL "Activates installation of monitoring")
45 ###########################################################################
47 link_libraries(-Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined)
49 add_compile_options(-Wall -Wextra -Wconversion)
50 add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care?
51 add_compile_options(-Wno-sign-compare -Wno-sign-conversion)
52 add_compile_options(-Werror=maybe-uninitialized)
53 add_compile_options(-Werror=implicit-function-declaration)
54 add_compile_options(-ffunction-sections -fdata-sections)
55 add_compile_options(-fPIC)
56 add_compile_options(-g)
58 set(CMAKE_C_FLAGS_PROFILING "-g -O2 -pg -Wp,-U_FORTIFY_SOURCE")
59 set(CMAKE_C_FLAGS_DEBUG "-g -ggdb -Wp,-U_FORTIFY_SOURCE")
60 set(CMAKE_C_FLAGS_RELEASE "-g -O2")
61 set(CMAKE_C_FLAGS_CCOV "-g -O2 --coverage")
63 ###########################################################################
68 PKG_CHECK_MODULES(json-c REQUIRED json-c)
70 CHECK_INCLUDE_FILES(magic.h HAVE_MAGIC_H)
71 CHECK_LIBRARY_EXISTS(magic magic_load "" HAVE_LIBMAGIC_SO)
74 SET(HAVE_LIBMAGIC "1")
75 ENDIF(HAVE_LIBMAGIC_SO)
79 MESSAGE(FATAL_ERROR "\"magic.h\" or \"libmagic.so\" missing.
80 Please install the \"file-devel\" or \"libmagic-dev\" package !")
81 ENDIF(NOT HAVE_LIBMAGIC)
82 ADD_DEFINITIONS(-DUSE_MAGIC_MIME_TYPE)
84 PKG_CHECK_MODULES(libsystemd REQUIRED libsystemd>=222)
85 PKG_CHECK_MODULES(libmicrohttpd REQUIRED libmicrohttpd>=0.9.55)
86 PKG_CHECK_MODULES(openssl REQUIRED openssl)
87 PKG_CHECK_MODULES(uuid REQUIRED uuid)
88 PKG_CHECK_MODULES(cynara cynara-client)
91 ADD_DEFINITIONS(-DAGL_DEVEL)
95 ADD_DEFINITIONS(-DBACKEND_PERMISSION_IS_CYNARA)
100 ${CMAKE_SOURCE_DIR}/include
101 ${json-c_INCLUDE_DIRS}
102 ${libsystemd_INCLUDE_DIRS}
103 ${libmicrohttpd_INCLUDE_DIRS}
105 ${openssl_INCLUDE_DIRS}
106 ${cynara_INCLUDE_DIRS}
110 ${CMAKE_THREAD_LIBS_INIT}
112 ${libsystemd_LDFLAGS}
113 ${libmicrohttpd_LDFLAGS}
122 SET(binding_install_dir ${CMAKE_INSTALL_FULL_LIBDIR}/afb)
124 ###########################################################################
125 # activates the monitoring by default
126 if(INCLUDE_MONITORING)
127 add_definitions(-DWITH_MONITORING_OPTION)
129 ${CMAKE_CURRENT_SOURCE_DIR}/test/monitoring
131 ${binding_install_dir}
135 ###########################################################################
137 ADD_SUBDIRECTORY(src)
138 ADD_SUBDIRECTORY(include)
139 ADD_SUBDIRECTORY(bindings)
141 ############################################################
142 # installs the pkgconfig files
143 CONFIGURE_FILE(afb-daemon.pc.in afb-daemon.pc @ONLY)
144 CONFIGURE_FILE(libafbwsc.pc.in libafbwsc.pc @ONLY)
147 ${CMAKE_CURRENT_BINARY_DIR}/afb-daemon.pc
148 ${CMAKE_CURRENT_BINARY_DIR}/libafbwsc.pc
150 ${CMAKE_INSTALL_LIBDIR}/pkgconfig