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)
63 ############################################################################
66 option(INCLUDE_SUPERVISOR "Activates installation of supervisor" OFF)
67 option(INCLUDE_MONITORING "Activates installation of monitoring" OFF)
68 option(INCLUDE_DBUS_TRANSPARENCY "Allows API transparency over DBUS" OFF)
69 option(INCLUDE_LEGACY_BINDING_V1 "Includes the legacy Binding API version 1" OFF)
70 option(INCLUDE_LEGACY_BINDING_VDYN "Includes the legacy Binding API version dynamic" OFF)
72 if(INCLUDE_SUPERVISOR)
73 set(WITH_SUPERVISOR ON)
75 if(INCLUDE_MONITORING)
76 set(WITH_MONITORING ON)
78 if(INCLUDE_DBUS_TRANSPARENCY)
79 set(WITH_DBUS_TRANSPARENCY ON)
81 if(INCLUDE_LEGACY_BINDING_V1)
82 set(WITH_LEGACY_BINDING_V1 ON)
84 if(INCLUDE_LEGACY_BINDING_VDYN)
85 set(WITH_LEGACY_BINDING_VDYN ON)
88 ###########################################################################
90 set(AFS_SUPERVISION_SOCKET "@urn:AGL:afs:supervision:socket" CACHE STRING "Internal socket for supervision")
91 set(AFS_SUPERVISOR_PORT 1619 CACHE STRING "Port of service for the supervisor")
92 set(AFS_SUPERVISOR_TOKEN HELLO CACHE STRING "Secret token for the supervisor")
93 set(UNITDIR_SYSTEM ${CMAKE_INSTALL_LIBDIR}/systemd/system CACHE STRING "Path to systemd system unit files")
95 ###########################################################################
97 link_libraries(-Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined)
99 add_compile_options(-Wall -Wextra -Wconversion)
100 add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care?
101 add_compile_options(-Wno-sign-compare -Wno-sign-conversion)
102 add_compile_options(-Werror=maybe-uninitialized)
103 add_compile_options(-Werror=implicit-function-declaration)
104 add_compile_options(-ffunction-sections -fdata-sections)
105 add_compile_options(-fPIC)
106 add_compile_options(-g)
107 set (CMAKE_CXX_STANDARD 14)
109 set(CMAKE_C_FLAGS_PROFILING "-g -O2 -pg -Wp,-U_FORTIFY_SOURCE")
110 set(CMAKE_C_FLAGS_DEBUG "-g -ggdb -Wp,-U_FORTIFY_SOURCE")
111 set(CMAKE_C_FLAGS_RELEASE "-g -O2")
112 set(CMAKE_C_FLAGS_CCOV "-g -O2 --coverage")
114 ###########################################################################
117 set(WITH_LIBMICROHTTPD OFF)
118 set(WITH_SYSTEMD OFF)
121 if(NOT WITH_LIBMICROHTTPD)
122 set(WITH_MONITORING OFF)
124 ###########################################################################
127 FIND_PACKAGE(Threads)
129 PKG_CHECK_MODULES(json-c REQUIRED json-c)
130 PKG_CHECK_MODULES(uuid uuid)
131 PKG_CHECK_MODULES(cynara cynara-client)
133 if(WITH_LIBMICROHTTPD)
135 CHECK_INCLUDE_FILES(magic.h HAVE_MAGIC_H)
136 CHECK_LIBRARY_EXISTS(magic magic_load "" HAVE_LIBMAGIC_SO)
137 if(HAVE_MAGIC_H AND HAVE_LIBMAGIC_SO)
138 SET(HAVE_LIBMAGIC "1")
139 SET(LIBMAGIC_LDFLAGS -lmagic)
141 MESSAGE(FATAL_ERROR "\"magic.h\" or \"libmagic.so\" missing.
142 Please install the \"file-devel\" or \"libmagic-dev\" package !")
144 PKG_CHECK_MODULES(libmicrohttpd REQUIRED libmicrohttpd>=0.9.60)
145 PKG_CHECK_MODULES(openssl REQUIRED openssl)
146 endif(WITH_LIBMICROHTTPD)
149 ADD_DEFINITIONS(-DBACKEND_PERMISSION_IS_CYNARA)
153 PKG_CHECK_MODULES(libsystemd REQUIRED libsystemd>=222)
155 PKG_CHECK_MODULES(libsystemd libsystemd>=222)
158 IF(NOT ONLY_DEVTOOLS)
160 MESSAGE(FATAL_ERROR "Dependency to 'uuid' is missing")
164 ADD_DEFINITIONS(-DAFB_VERSION="${PROJECT_VERSION}")
168 ${CMAKE_SOURCE_DIR}/include
169 ${json-c_INCLUDE_DIRS}
170 ${libsystemd_INCLUDE_DIRS}
171 ${libmicrohttpd_INCLUDE_DIRS}
173 ${openssl_INCLUDE_DIRS}
174 ${cynara_INCLUDE_DIRS}
178 ${CMAKE_THREAD_LIBS_INIT}
180 ${libsystemd_LDFLAGS}
181 ${libmicrohttpd_LDFLAGS}
190 ADD_SUBDIRECTORY(src/devtools)
193 MESSAGE(WARNING "Only DEVTOOLS are compiled, not the binder!")
195 SET(binding_install_dir ${CMAKE_INSTALL_FULL_LIBDIR}/afb)
197 ###########################################################################
198 # activates the monitoring by default
201 ${CMAKE_CURRENT_SOURCE_DIR}/test/monitoring
203 ${binding_install_dir}
207 ###########################################################################
209 ADD_SUBDIRECTORY(src)
210 ADD_SUBDIRECTORY(src/tests)
211 ADD_SUBDIRECTORY(include)
212 ADD_SUBDIRECTORY(bindings)
214 ############################################################
215 # installs the pkgconfig files
216 CONFIGURE_FILE(afb-daemon.pc.in afb-daemon.pc @ONLY)
217 CONFIGURE_FILE(libafbwsc.pc.in libafbwsc.pc @ONLY)
220 ${CMAKE_CURRENT_BINARY_DIR}/afb-daemon.pc
221 ${CMAKE_CURRENT_BINARY_DIR}/libafbwsc.pc
223 ${CMAKE_INSTALL_LIBDIR}/pkgconfig
228 IF(INCLUDE_SUPERVISOR)
229 CONFIGURE_FILE(afs-supervisor.service.in afs-supervisor.service @ONLY)
231 ${CMAKE_CURRENT_BINARY_DIR}/afs-supervisor.service