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 ###########################################################################
19 CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
21 PROJECT(afb-daemon C CXX)
23 SET(PROJECT_NAME "AFB Daemon")
24 SET(PROJECT_PRETTY_NAME "Application Framework Binder Daemon")
25 SET(PROJECT_DESCRIPTION "Secured binder of API for clients of the Application framework")
26 SET(PROJECT_VERSION "4.99-EERC1")
27 set(PROJECT_URL "https://gerrit.automotivelinux.org/gerrit/gitweb?p=src/app-framework-binder.git;a=summary")
29 SET(LIBAFBWSC_VERSION "1.1")
30 SET(LIBAFBWSC_SOVERSION "1")
32 INCLUDE(FindPkgConfig)
33 INCLUDE(CheckIncludeFiles)
34 INCLUDE(CheckLibraryExists)
35 INCLUDE(GNUInstallDirs)
38 ###########################################################################
40 set(AGL_DEVEL OFF CACHE BOOL "Activates developping features")
41 set(INCLUDE_MONITORING OFF CACHE BOOL "Activates installation of monitoring")
43 ###########################################################################
45 link_libraries(-Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined)
47 add_compile_options(-Wall -Wextra -Wconversion)
48 add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care?
49 add_compile_options(-Wno-sign-compare -Wno-sign-conversion)
50 add_compile_options(-Werror=maybe-uninitialized)
51 add_compile_options(-Werror=implicit-function-declaration)
52 add_compile_options(-ffunction-sections -fdata-sections)
53 add_compile_options(-fPIC)
54 add_compile_options(-g)
56 set(CMAKE_C_FLAGS_PROFILING "-g -O2 -pg -Wp,-U_FORTIFY_SOURCE")
57 set(CMAKE_C_FLAGS_DEBUG "-g -ggdb -Wp,-U_FORTIFY_SOURCE")
58 set(CMAKE_C_FLAGS_RELEASE "-g -O2")
59 set(CMAKE_C_FLAGS_CCOV "-g -O2 --coverage")
61 ###########################################################################
66 PKG_CHECK_MODULES(json-c REQUIRED json-c)
68 CHECK_INCLUDE_FILES(magic.h HAVE_MAGIC_H)
69 CHECK_LIBRARY_EXISTS(magic magic_load "" HAVE_LIBMAGIC_SO)
72 SET(HAVE_LIBMAGIC "1")
73 SET(LIBMAGIC_LDFLAGS -lmagic)
74 ENDIF(HAVE_LIBMAGIC_SO)
77 PKG_CHECK_MODULES(libsystemd libsystemd>=222)
78 PKG_CHECK_MODULES(libmicrohttpd libmicrohttpd>=0.9.55)
79 PKG_CHECK_MODULES(openssl openssl)
80 PKG_CHECK_MODULES(uuid uuid)
81 PKG_CHECK_MODULES(cynara cynara-client)
84 ADD_DEFINITIONS(-DAGL_DEVEL)
88 ADD_DEFINITIONS(-DBACKEND_PERMISSION_IS_CYNARA)
91 IF(HAVE_LIBMAGIC AND libsystemd_FOUND AND libmicrohttpd_FOUND AND openssl_FOUND AND uuid_FOUND)
92 ADD_DEFINITIONS(-DUSE_MAGIC_MIME_TYPE)
95 MESSAGE(WARNING "\"magic.h\" or \"libmagic.so\" missing.
96 Please install the \"file-devel\" or \"libmagic-dev\" package !")
97 ENDIF(NOT HAVE_LIBMAGIC)
98 IF(NOT libsystemd_FOUND)
99 MESSAGE(WARNING "Dependency to 'libsystemd' is missing")
101 IF(NOT libmicrohttpd_FOUND)
102 MESSAGE(WARNING "Dependency to 'libmicrohttpd' is missing")
104 IF(NOT openssl_FOUND)
105 MESSAGE(WARNING "Dependency to 'openssl' is missing")
108 MESSAGE(WARNING "Dependency to 'uuid' is missing")
110 IF(NOT ONLY_DEVTOOLS)
111 MESSAGE(FATAL_ERROR "Can't compile the binder, either define ONLY_DEVTOOLS or install dependencies")
115 ADD_DEFINITIONS(-DAFB_VERSION="${PROJECT_VERSION}")
119 ${CMAKE_SOURCE_DIR}/include
120 ${json-c_INCLUDE_DIRS}
121 ${libsystemd_INCLUDE_DIRS}
122 ${libmicrohttpd_INCLUDE_DIRS}
124 ${openssl_INCLUDE_DIRS}
125 ${cynara_INCLUDE_DIRS}
129 ${CMAKE_THREAD_LIBS_INIT}
131 ${libsystemd_LDFLAGS}
132 ${libmicrohttpd_LDFLAGS}
141 ADD_SUBDIRECTORY(src/devtools)
144 MESSAGE(WARNING "Only DEVTOOLS are compiled, not the binder!")
146 SET(binding_install_dir ${CMAKE_INSTALL_FULL_LIBDIR}/afb)
148 ###########################################################################
149 # activates the monitoring by default
150 if(INCLUDE_MONITORING AND NOT ONLY_DEVTOOLS)
151 add_definitions(-DWITH_MONITORING_OPTION)
153 ${CMAKE_CURRENT_SOURCE_DIR}/test/monitoring
155 ${binding_install_dir}
159 ###########################################################################
161 ADD_SUBDIRECTORY(src)
162 ADD_SUBDIRECTORY(src/tests)
163 ADD_SUBDIRECTORY(include)
164 ADD_SUBDIRECTORY(bindings)
166 ############################################################
167 # installs the pkgconfig files
168 CONFIGURE_FILE(afb-daemon.pc.in afb-daemon.pc @ONLY)
169 CONFIGURE_FILE(libafbwsc.pc.in libafbwsc.pc @ONLY)
172 ${CMAKE_CURRENT_BINARY_DIR}/afb-daemon.pc
173 ${CMAKE_CURRENT_BINARY_DIR}/libafbwsc.pc
175 ${CMAKE_INSTALL_LIBDIR}/pkgconfig