1 ###########################################################################
2 # Copyright (C) 2015-2019 "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(AGLVERSION "8.0.0" CACHE STRING "Version of AGL")
27 set(PROJECT_VERSION ${AGLVERSION} CACHE STRING "Version of the project can override AGLVERSION")
28 set(PROJECT_URL "https://gerrit.automotivelinux.org/gerrit/gitweb?p=src/app-framework-binder.git;a=summary")
30 SET(LIBAFBWSC_VERSION "1.1")
31 SET(LIBAFBWSC_SOVERSION "1")
33 INCLUDE(FindPkgConfig)
34 INCLUDE(CheckIncludeFiles)
35 INCLUDE(CheckLibraryExists)
36 INCLUDE(GNUInstallDirs)
39 ###########################################################################
42 option(ONLY_DEVTOOLS "Produces only development tools" OFF)
43 option(AGL_DEVEL "Activates developping features" OFF)
44 option(WITH_SYSTEMD "Require use of libsystemd" ON)
46 ############################################################################
48 option(WITH_SIG_MONITOR_DUMPSTACK "Activate dump stack on error" ON)
49 option(WITH_SIG_MONITOR_SIGNALS "Activate handling of signals" ON)
50 option(WITH_SIG_MONITOR_FOR_CALL "Activate monitoring of calls" ON)
51 option(WITH_SIG_MONITOR_TIMERS "Activate monitoring of call expiration" ON)
52 option(WITH_AFB_HOOK "Include hooking" ON)
53 option(WITH_AFB_TRACE "Include monitoring trace" ON)
54 option(WITH_SUPERVISOR "Activates installation of supervisor" OFF)
55 option(WITH_MONITORING "Activates installation of monitoring" OFF)
56 option(WITH_DBUS_TRANSPARENCY "Allows API transparency over DBUS" OFF)
57 option(WITH_LEGACY_BINDING_V1 "Includes the legacy Binding API version 1" OFF)
58 option(WITH_LEGACY_BINDING_V2 "Includes the legacy Binding API version 2" ON)
59 option(WITH_LEGACY_BINDING_VDYN "Includes the legacy Binding API version dynamic" OFF)
60 option(WITH_DYNAMIC_BINDING "Allow to load dynamic bindings (shared libraries)" ON)
61 option(WITH_LIBMICROHTTPD "Activates HTTP server through LIBMICROHTTPD" ON)
62 option(WITH_FNMATCH "Use fnmatch where possible" ON)
64 ############################################################################
67 option(INCLUDE_SUPERVISOR "Activates installation of supervisor" OFF)
68 option(INCLUDE_MONITORING "Activates installation of monitoring" OFF)
69 option(INCLUDE_DBUS_TRANSPARENCY "Allows API transparency over DBUS" OFF)
70 option(INCLUDE_LEGACY_BINDING_V1 "Includes the legacy Binding API version 1" OFF)
71 option(INCLUDE_LEGACY_BINDING_VDYN "Includes the legacy Binding API version dynamic" OFF)
73 if(INCLUDE_SUPERVISOR)
74 set(WITH_SUPERVISOR ON)
76 if(INCLUDE_MONITORING)
77 set(WITH_MONITORING ON)
79 if(INCLUDE_DBUS_TRANSPARENCY)
80 set(WITH_DBUS_TRANSPARENCY ON)
82 if(INCLUDE_LEGACY_BINDING_V1)
83 set(WITH_LEGACY_BINDING_V1 ON)
85 if(INCLUDE_LEGACY_BINDING_VDYN)
86 set(WITH_LEGACY_BINDING_VDYN ON)
89 ###########################################################################
91 set(AFS_SUPERVISION_SOCKET "@urn:AGL:afs:supervision:socket" CACHE STRING "Internal socket for supervision")
92 set(AFS_SUPERVISOR_PORT 1619 CACHE STRING "Port of service for the supervisor")
93 set(AFS_SUPERVISOR_TOKEN HELLO CACHE STRING "Secret token for the supervisor")
94 set(UNITDIR_SYSTEM ${CMAKE_INSTALL_LIBDIR}/systemd/system CACHE STRING "Path to systemd system unit files")
96 ###########################################################################
98 link_libraries(-Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined)
100 add_compile_options(-Wall -Wextra -Wconversion)
101 add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care?
102 add_compile_options(-Wno-sign-compare -Wno-sign-conversion)
103 add_compile_options(-Werror=maybe-uninitialized)
104 add_compile_options(-Werror=implicit-function-declaration)
105 add_compile_options(-ffunction-sections -fdata-sections)
106 add_compile_options(-fPIC)
107 add_compile_options(-g)
108 set (CMAKE_CXX_STANDARD 14)
110 set(CMAKE_C_FLAGS_PROFILING "-g -O2 -pg -Wp,-U_FORTIFY_SOURCE")
111 set(CMAKE_C_FLAGS_DEBUG "-g -ggdb -Wp,-U_FORTIFY_SOURCE")
112 set(CMAKE_C_FLAGS_RELEASE "-g -O2")
113 set(CMAKE_C_FLAGS_CCOV "-g -O2 --coverage")
115 ###########################################################################
118 set(WITH_LIBMICROHTTPD OFF)
119 set(WITH_SYSTEMD OFF)
122 if(NOT WITH_LIBMICROHTTPD)
123 set(WITH_MONITORING OFF)
125 ###########################################################################
128 FIND_PACKAGE(Threads)
130 PKG_CHECK_MODULES(json-c REQUIRED json-c)
131 PKG_CHECK_MODULES(uuid uuid)
132 PKG_CHECK_MODULES(cynara cynara-client)
134 if(WITH_LIBMICROHTTPD)
136 CHECK_INCLUDE_FILES(magic.h HAVE_MAGIC_H)
137 CHECK_LIBRARY_EXISTS(magic magic_load "" HAVE_LIBMAGIC_SO)
138 if(HAVE_MAGIC_H AND HAVE_LIBMAGIC_SO)
139 SET(HAVE_LIBMAGIC "1")
140 SET(LIBMAGIC_LDFLAGS -lmagic)
142 MESSAGE(FATAL_ERROR "\"magic.h\" or \"libmagic.so\" missing.
143 Please install the \"file-devel\" or \"libmagic-dev\" package !")
145 PKG_CHECK_MODULES(libmicrohttpd REQUIRED libmicrohttpd>=0.9.60)
146 PKG_CHECK_MODULES(openssl REQUIRED openssl)
147 endif(WITH_LIBMICROHTTPD)
150 ADD_DEFINITIONS(-DBACKEND_PERMISSION_IS_CYNARA)
154 PKG_CHECK_MODULES(libsystemd REQUIRED libsystemd>=222)
156 PKG_CHECK_MODULES(libsystemd libsystemd>=222)
159 IF(NOT ONLY_DEVTOOLS)
161 MESSAGE(FATAL_ERROR "Dependency to 'uuid' is missing")
165 ADD_DEFINITIONS(-DAFB_VERSION="${PROJECT_VERSION}")
169 ${CMAKE_SOURCE_DIR}/include
170 ${json-c_INCLUDE_DIRS}
171 ${libsystemd_INCLUDE_DIRS}
172 ${libmicrohttpd_INCLUDE_DIRS}
174 ${openssl_INCLUDE_DIRS}
175 ${cynara_INCLUDE_DIRS}
179 ${CMAKE_THREAD_LIBS_INIT}
181 ${libsystemd_LDFLAGS}
182 ${libmicrohttpd_LDFLAGS}
191 ADD_SUBDIRECTORY(src/devtools)
194 MESSAGE(WARNING "Only DEVTOOLS are compiled, not the binder!")
196 SET(binding_install_dir ${CMAKE_INSTALL_FULL_LIBDIR}/afb)
198 ###########################################################################
199 # activates the monitoring by default
202 ${CMAKE_CURRENT_SOURCE_DIR}/test/monitoring
204 ${binding_install_dir}
208 ###########################################################################
210 ADD_SUBDIRECTORY(src)
211 ADD_SUBDIRECTORY(src/tests)
212 ADD_SUBDIRECTORY(include)
213 ADD_SUBDIRECTORY(bindings)
215 ############################################################
216 # installs the pkgconfig files
217 CONFIGURE_FILE(afb-daemon.pc.in afb-daemon.pc @ONLY)
218 CONFIGURE_FILE(libafbwsc.pc.in libafbwsc.pc @ONLY)
221 ${CMAKE_CURRENT_BINARY_DIR}/afb-daemon.pc
222 ${CMAKE_CURRENT_BINARY_DIR}/libafbwsc.pc
224 ${CMAKE_INSTALL_LIBDIR}/pkgconfig
229 IF(INCLUDE_SUPERVISOR)
230 CONFIGURE_FILE(afs-supervisor.service.in afs-supervisor.service @ONLY)
232 ${CMAKE_CURRENT_BINARY_DIR}/afs-supervisor.service