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)
63 option(WITH_L4VSOCK "Activates L4RE support of VIRTIO-SOCKS" OFF)
65 ############################################################################
68 option(INCLUDE_SUPERVISOR "Activates installation of supervisor" OFF)
69 option(INCLUDE_MONITORING "Activates installation of monitoring" OFF)
70 option(INCLUDE_DBUS_TRANSPARENCY "Allows API transparency over DBUS" OFF)
71 option(INCLUDE_LEGACY_BINDING_V1 "Includes the legacy Binding API version 1" OFF)
72 option(INCLUDE_LEGACY_BINDING_VDYN "Includes the legacy Binding API version dynamic" OFF)
74 if(INCLUDE_SUPERVISOR)
75 set(WITH_SUPERVISOR ON)
77 if(INCLUDE_MONITORING)
78 set(WITH_MONITORING ON)
80 if(INCLUDE_DBUS_TRANSPARENCY)
81 set(WITH_DBUS_TRANSPARENCY ON)
83 if(INCLUDE_LEGACY_BINDING_V1)
84 set(WITH_LEGACY_BINDING_V1 ON)
86 if(INCLUDE_LEGACY_BINDING_VDYN)
87 set(WITH_LEGACY_BINDING_VDYN ON)
90 ###########################################################################
92 set(AFS_SUPERVISION_SOCKET "@urn:AGL:afs:supervision:socket" CACHE STRING "Internal socket for supervision")
93 set(AFS_SUPERVISOR_PORT 1619 CACHE STRING "Port of service for the supervisor")
94 set(AFS_SUPERVISOR_TOKEN HELLO CACHE STRING "Secret token for the supervisor")
95 set(UNITDIR_SYSTEM ${CMAKE_INSTALL_LIBDIR}/systemd/system CACHE STRING "Path to systemd system unit files")
97 ###########################################################################
99 link_libraries(-Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined)
101 add_compile_options(-Wall -Wextra -Wconversion)
102 add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care?
103 add_compile_options(-Wno-sign-compare -Wno-sign-conversion)
104 add_compile_options(-Werror=maybe-uninitialized)
105 add_compile_options(-Werror=implicit-function-declaration)
106 add_compile_options(-ffunction-sections -fdata-sections)
107 add_compile_options(-fPIC)
108 add_compile_options(-g)
109 set (CMAKE_CXX_STANDARD 14)
111 set(CMAKE_C_FLAGS_PROFILING "-g -O2 -pg -Wp,-U_FORTIFY_SOURCE")
112 set(CMAKE_C_FLAGS_DEBUG "-g -ggdb -Wp,-U_FORTIFY_SOURCE")
113 set(CMAKE_C_FLAGS_RELEASE "-g -O2")
114 set(CMAKE_C_FLAGS_CCOV "-g -O2 --coverage")
116 ###########################################################################
119 set(WITH_LIBMICROHTTPD OFF)
120 set(WITH_SYSTEMD OFF)
123 if(NOT WITH_LIBMICROHTTPD)
124 set(WITH_MONITORING OFF)
126 ###########################################################################
129 FIND_PACKAGE(Threads)
131 PKG_CHECK_MODULES(json-c REQUIRED json-c)
132 PKG_CHECK_MODULES(uuid uuid)
133 PKG_CHECK_MODULES(cynara cynara-client)
135 if(WITH_LIBMICROHTTPD)
137 CHECK_INCLUDE_FILES(magic.h HAVE_MAGIC_H)
138 CHECK_LIBRARY_EXISTS(magic magic_load "" HAVE_LIBMAGIC_SO)
139 if(HAVE_MAGIC_H AND HAVE_LIBMAGIC_SO)
140 SET(HAVE_LIBMAGIC "1")
141 SET(LIBMAGIC_LDFLAGS -lmagic)
143 MESSAGE(FATAL_ERROR "\"magic.h\" or \"libmagic.so\" missing.
144 Please install the \"file-devel\" or \"libmagic-dev\" package !")
146 PKG_CHECK_MODULES(libmicrohttpd REQUIRED libmicrohttpd>=0.9.60)
147 PKG_CHECK_MODULES(openssl REQUIRED openssl)
148 endif(WITH_LIBMICROHTTPD)
151 ADD_DEFINITIONS(-DBACKEND_PERMISSION_IS_CYNARA)
155 PKG_CHECK_MODULES(libsystemd REQUIRED libsystemd>=222)
157 PKG_CHECK_MODULES(libsystemd libsystemd>=222)
160 IF(NOT ONLY_DEVTOOLS)
162 MESSAGE(FATAL_ERROR "Dependency to 'uuid' is missing")
166 ADD_DEFINITIONS(-DAFB_VERSION="${PROJECT_VERSION}")
170 ${CMAKE_SOURCE_DIR}/include
171 ${json-c_INCLUDE_DIRS}
172 ${libsystemd_INCLUDE_DIRS}
173 ${libmicrohttpd_INCLUDE_DIRS}
175 ${openssl_INCLUDE_DIRS}
176 ${cynara_INCLUDE_DIRS}
180 ${CMAKE_THREAD_LIBS_INIT}
182 ${libsystemd_LDFLAGS}
183 ${libmicrohttpd_LDFLAGS}
192 ADD_SUBDIRECTORY(src/devtools)
195 MESSAGE(WARNING "Only DEVTOOLS are compiled, not the binder!")
197 SET(binding_install_dir ${CMAKE_INSTALL_FULL_LIBDIR}/afb)
199 ###########################################################################
200 # activates the monitoring by default
203 ${CMAKE_CURRENT_SOURCE_DIR}/test/monitoring
205 ${binding_install_dir}
209 ###########################################################################
211 ADD_SUBDIRECTORY(src)
212 ADD_SUBDIRECTORY(src/tests)
213 ADD_SUBDIRECTORY(include)
214 ADD_SUBDIRECTORY(bindings)
216 ############################################################
217 # installs the pkgconfig files
218 CONFIGURE_FILE(afb-daemon.pc.in afb-daemon.pc @ONLY)
219 CONFIGURE_FILE(libafbwsc.pc.in libafbwsc.pc @ONLY)
222 ${CMAKE_CURRENT_BINARY_DIR}/afb-daemon.pc
223 ${CMAKE_CURRENT_BINARY_DIR}/libafbwsc.pc
225 ${CMAKE_INSTALL_LIBDIR}/pkgconfig
230 IF(INCLUDE_SUPERVISOR)
231 CONFIGURE_FILE(afs-supervisor.service.in afs-supervisor.service @ONLY)
233 ${CMAKE_CURRENT_BINARY_DIR}/afs-supervisor.service