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(AGL_DEVEL "Activates developping features" OFF)
43 option(INCLUDE_MONITORING "Activates installation of monitoring" OFF)
45 option(INCLUDE_SUPERVISOR "Activates installation of supervisor" OFF)
46 option(INCLUDE_DBUS_TRANSPARENCY "Allows API transparency over DBUS" OFF)
47 option(INCLUDE_LEGACY_BINDING_V1 "Includes the legacy Binding API version 1" OFF)
48 option(INCLUDE_LEGACY_BINDING_VDYN "Includes the legacy Binding API version dynamic" OFF)
50 set(AFS_SUPERVISION_SOCKET "@urn:AGL:afs:supervision:socket" CACHE STRING "Internal socket for supervision")
51 set(AFS_SUPERVISOR_PORT 1619 CACHE STRING "Port of service for the supervisor")
52 set(AFS_SUPERVISOR_TOKEN HELLO CACHE STRING "Secret token for the supervisor")
53 set(UNITDIR_SYSTEM ${CMAKE_INSTALL_LIBDIR}/systemd/system CACHE STRING "Path to systemd system unit files")
54 set(INTRINSIC_BINDING_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/afb CACHE STRING "Path to install intrinsic bindings")
55 set(SAMPLE_INSTALL_DIR ${CMAKE_INSTALL_FULL_DATADIR}/af-binder CACHE STRING "Path to install samples")
57 ###########################################################################
59 link_libraries(-Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined)
61 add_compile_options(-Wall -Wextra -Wconversion)
62 add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care?
63 add_compile_options(-Wno-sign-compare -Wno-sign-conversion)
64 if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
65 add_compile_options(-Werror=maybe-uninitialized)
66 elseif(${CMAKE_C_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
67 add_compile_options(-Werror=sometimes-uninitialized)
69 add_compile_options(-Werror=implicit-function-declaration)
70 add_compile_options(-ffunction-sections -fdata-sections)
71 add_compile_options(-fPIC)
72 add_compile_options(-g -O2)
73 set (CMAKE_CXX_STANDARD 14)
75 set(CMAKE_C_FLAGS_PROFILING "-g -O2 -pg -U_FORTIFY_SOURCE")
76 set(CMAKE_C_FLAGS_DEBUG "-g -O2 -ggdb -U_FORTIFY_SOURCE")
77 set(CMAKE_C_FLAGS_RELEASE "-g -O3")
78 set(CMAKE_C_FLAGS_CCOV "-g -O2 --coverage")
80 ###########################################################################
85 PKG_CHECK_MODULES(json-c REQUIRED json-c)
87 CHECK_INCLUDE_FILES(magic.h HAVE_MAGIC_H)
88 CHECK_LIBRARY_EXISTS(magic magic_load "" HAVE_LIBMAGIC_SO)
91 SET(HAVE_LIBMAGIC "1")
92 SET(LIBMAGIC_LDFLAGS -lmagic)
93 ENDIF(HAVE_LIBMAGIC_SO)
96 PKG_CHECK_MODULES(libsystemd libsystemd>=222)
97 PKG_CHECK_MODULES(libmicrohttpd libmicrohttpd>=0.9.60)
98 PKG_CHECK_MODULES(openssl openssl)
99 PKG_CHECK_MODULES(uuid uuid)
100 PKG_CHECK_MODULES(cynara cynara-client)
102 ADD_DEFINITIONS("-DAFS_SUPERVISION_SOCKET=\"${AFS_SUPERVISION_SOCKET}\"")
103 ADD_DEFINITIONS("-DAFS_SUPERVISOR_TOKEN=\"${AFS_SUPERVISOR_TOKEN}\"")
104 ADD_DEFINITIONS("-DAFS_SUPERVISOR_PORT=${AFS_SUPERVISOR_PORT}")
107 ADD_DEFINITIONS(-DBACKEND_PERMISSION_IS_CYNARA)
110 IF(HAVE_LIBMAGIC AND libsystemd_FOUND AND libmicrohttpd_FOUND AND openssl_FOUND AND uuid_FOUND)
111 ADD_DEFINITIONS(-DUSE_MAGIC_MIME_TYPE)
113 IF(NOT HAVE_LIBMAGIC)
114 MESSAGE(WARNING "\"magic.h\" or \"libmagic.so\" missing.
115 Please install the \"file-devel\" or \"libmagic-dev\" package !")
116 ENDIF(NOT HAVE_LIBMAGIC)
117 IF(NOT libsystemd_FOUND)
118 MESSAGE(WARNING "Dependency to 'libsystemd' is missing")
120 IF(NOT libmicrohttpd_FOUND)
121 MESSAGE(WARNING "Dependency to 'libmicrohttpd' is missing")
123 IF(NOT openssl_FOUND)
124 MESSAGE(WARNING "Dependency to 'openssl' is missing")
127 MESSAGE(WARNING "Dependency to 'uuid' is missing")
129 IF(NOT ONLY_DEVTOOLS)
130 MESSAGE(FATAL_ERROR "Can't compile the binder, either define ONLY_DEVTOOLS or install dependencies")
134 ADD_DEFINITIONS(-DAFB_VERSION="${PROJECT_VERSION}")
138 ${CMAKE_SOURCE_DIR}/include
139 ${json-c_INCLUDE_DIRS}
140 ${libsystemd_INCLUDE_DIRS}
141 ${libmicrohttpd_INCLUDE_DIRS}
143 ${openssl_INCLUDE_DIRS}
144 ${cynara_INCLUDE_DIRS}
148 ${CMAKE_THREAD_LIBS_INIT}
150 ${libsystemd_LDFLAGS}
151 ${libmicrohttpd_LDFLAGS}
160 ADD_SUBDIRECTORY(src/devtools)
163 MESSAGE(WARNING "Only DEVTOOLS are compiled, not the binder!")
166 ###########################################################################
167 # activates the monitoring by default
168 if(INCLUDE_MONITORING AND NOT ONLY_DEVTOOLS)
169 add_definitions(-DWITH_MONITORING_OPTION)
171 ${CMAKE_CURRENT_SOURCE_DIR}/test/monitoring
173 ${INTRINSIC_BINDING_DIR}
177 ###########################################################################
179 ADD_SUBDIRECTORY(src)
180 ADD_SUBDIRECTORY(src/tests)
181 ADD_SUBDIRECTORY(include)
182 ADD_SUBDIRECTORY(bindings)
184 ############################################################
185 # installs the pkgconfig files
186 CONFIGURE_FILE(afb-daemon.pc.in afb-daemon.pc @ONLY)
187 CONFIGURE_FILE(libafbwsc.pc.in libafbwsc.pc @ONLY)
190 ${CMAKE_CURRENT_BINARY_DIR}/afb-daemon.pc
191 ${CMAKE_CURRENT_BINARY_DIR}/libafbwsc.pc
193 ${CMAKE_INSTALL_LIBDIR}/pkgconfig
198 IF(INCLUDE_SUPERVISOR)
199 CONFIGURE_FILE(afs-supervisor.service.in afs-supervisor.service @ONLY)
201 ${CMAKE_CURRENT_SOURCE_DIR}/afm-api-supervisor.service
202 ${CMAKE_CURRENT_SOURCE_DIR}/afm-api-supervisor.socket
203 ${CMAKE_CURRENT_BINARY_DIR}/afs-supervisor.service