1 ###########################################################################
2 # Copyright (C) 2015-2018 "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 "5.99-FFRC0")
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")
42 set(INCLUDE_SUPERVISOR OFF CACHE BOOL "Activates installation of supervisor")
43 set(AFS_SURPERVISION_SOCKET "@urn:AGL:afs:supervision:socket" CACHE STRING "Internal socket for supervision")
44 set(AFS_SUPERVISOR_PORT 1619 CACHE STRING "Port of service for the supervisor")
45 set(AFS_SUPERVISOR_TOKEN HELLO CACHE STRING "Secret token for the supervisor")
46 set(UNITDIR_SYSTEM ${CMAKE_INSTALL_LIBDIR}/systemd/system CACHE STRING "Path to systemd system unit files")
48 ###########################################################################
50 link_libraries(-Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined)
52 add_compile_options(-Wall -Wextra -Wconversion)
53 add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care?
54 add_compile_options(-Wno-sign-compare -Wno-sign-conversion)
55 add_compile_options(-Werror=maybe-uninitialized)
56 add_compile_options(-Werror=implicit-function-declaration)
57 add_compile_options(-ffunction-sections -fdata-sections)
58 add_compile_options(-fPIC)
59 add_compile_options(-g)
60 set (CMAKE_CXX_STANDARD 14)
62 set(CMAKE_C_FLAGS_PROFILING "-g -O2 -pg -Wp,-U_FORTIFY_SOURCE")
63 set(CMAKE_C_FLAGS_DEBUG "-g -ggdb -Wp,-U_FORTIFY_SOURCE")
64 set(CMAKE_C_FLAGS_RELEASE "-g -O2")
65 set(CMAKE_C_FLAGS_CCOV "-g -O2 --coverage")
67 ###########################################################################
72 PKG_CHECK_MODULES(json-c REQUIRED json-c)
74 CHECK_INCLUDE_FILES(magic.h HAVE_MAGIC_H)
75 CHECK_LIBRARY_EXISTS(magic magic_load "" HAVE_LIBMAGIC_SO)
78 SET(HAVE_LIBMAGIC "1")
79 SET(LIBMAGIC_LDFLAGS -lmagic)
80 ENDIF(HAVE_LIBMAGIC_SO)
83 PKG_CHECK_MODULES(libsystemd libsystemd>=222)
84 PKG_CHECK_MODULES(libmicrohttpd libmicrohttpd>=0.9.55)
85 PKG_CHECK_MODULES(openssl openssl)
86 PKG_CHECK_MODULES(uuid uuid)
87 PKG_CHECK_MODULES(cynara cynara-client)
89 ADD_DEFINITIONS("-DAFS_SURPERVISION_SOCKET=\"${AFS_SURPERVISION_SOCKET}\"")
92 ADD_DEFINITIONS(-DAGL_DEVEL)
96 ADD_DEFINITIONS(-DBACKEND_PERMISSION_IS_CYNARA)
99 IF(HAVE_LIBMAGIC AND libsystemd_FOUND AND libmicrohttpd_FOUND AND openssl_FOUND AND uuid_FOUND)
100 ADD_DEFINITIONS(-DUSE_MAGIC_MIME_TYPE)
102 IF(NOT HAVE_LIBMAGIC)
103 MESSAGE(WARNING "\"magic.h\" or \"libmagic.so\" missing.
104 Please install the \"file-devel\" or \"libmagic-dev\" package !")
105 ENDIF(NOT HAVE_LIBMAGIC)
106 IF(NOT libsystemd_FOUND)
107 MESSAGE(WARNING "Dependency to 'libsystemd' is missing")
109 IF(NOT libmicrohttpd_FOUND)
110 MESSAGE(WARNING "Dependency to 'libmicrohttpd' is missing")
112 IF(NOT openssl_FOUND)
113 MESSAGE(WARNING "Dependency to 'openssl' is missing")
116 MESSAGE(WARNING "Dependency to 'uuid' is missing")
118 IF(NOT ONLY_DEVTOOLS)
119 MESSAGE(FATAL_ERROR "Can't compile the binder, either define ONLY_DEVTOOLS or install dependencies")
123 ADD_DEFINITIONS(-DAFB_VERSION="${PROJECT_VERSION}")
127 ${CMAKE_SOURCE_DIR}/include
128 ${json-c_INCLUDE_DIRS}
129 ${libsystemd_INCLUDE_DIRS}
130 ${libmicrohttpd_INCLUDE_DIRS}
132 ${openssl_INCLUDE_DIRS}
133 ${cynara_INCLUDE_DIRS}
137 ${CMAKE_THREAD_LIBS_INIT}
139 ${libsystemd_LDFLAGS}
140 ${libmicrohttpd_LDFLAGS}
149 ADD_SUBDIRECTORY(src/devtools)
152 MESSAGE(WARNING "Only DEVTOOLS are compiled, not the binder!")
154 SET(binding_install_dir ${CMAKE_INSTALL_FULL_LIBDIR}/afb)
156 ###########################################################################
157 # activates the monitoring by default
158 if(INCLUDE_MONITORING AND NOT ONLY_DEVTOOLS)
159 add_definitions(-DWITH_MONITORING_OPTION)
161 ${CMAKE_CURRENT_SOURCE_DIR}/test/monitoring
163 ${binding_install_dir}
167 ###########################################################################
169 ADD_SUBDIRECTORY(src)
170 ADD_SUBDIRECTORY(src/tests)
171 ADD_SUBDIRECTORY(include)
172 ADD_SUBDIRECTORY(bindings)
174 ############################################################
175 # installs the pkgconfig files
176 CONFIGURE_FILE(afb-daemon.pc.in afb-daemon.pc @ONLY)
177 CONFIGURE_FILE(libafbwsc.pc.in libafbwsc.pc @ONLY)
180 ${CMAKE_CURRENT_BINARY_DIR}/afb-daemon.pc
181 ${CMAKE_CURRENT_BINARY_DIR}/libafbwsc.pc
183 ${CMAKE_INSTALL_LIBDIR}/pkgconfig
188 IF(INCLUDE_SUPERVISOR)
189 CONFIGURE_FILE(afs-supervisor.service.in afs-supervisor.service @ONLY)
191 ${CMAKE_CURRENT_BINARY_DIR}/afs-supervisor.service