Bump version to 4.99-EERC1
[src/app-framework-binder.git] / CMakeLists.txt
1 ###########################################################################
2 # Copyright 2015, 2016, 2017 IoT.bzh
3 #
4 # author: José Bollo <jose.bollo@iot.bzh>
5 #
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
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
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 ###########################################################################
18
19 CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
20
21 PROJECT(afb-daemon C)
22
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 "4.99-EERC1")
27 set(PROJECT_URL "https://gerrit.automotivelinux.org/gerrit/gitweb?p=src/app-framework-binder.git;a=summary")
28
29 SET(LIBAFBWSC_VERSION "1.0")
30 SET(LIBAFBWSC_SOVERSION "1")
31
32 SET(CMAKE_BUILD_TYPE Debug)
33 SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
34
35 INCLUDE(FindPkgConfig)
36 INCLUDE(CheckIncludeFiles)
37 INCLUDE(CheckLibraryExists)
38 INCLUDE(GNUInstallDirs)
39 INCLUDE(CTest)
40
41 ###########################################################################
42 # possible settings
43 set(AGL_DEVEL OFF CACHE BOOL "Activates developping features")
44 set(INCLUDE_MONITORING OFF CACHE BOOL "Activates installation of monitoring")
45
46 ###########################################################################
47
48 link_libraries(-Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined)
49
50 add_compile_options(-Wall -Wextra -Wconversion)
51 add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care?
52 add_compile_options(-Wno-sign-compare -Wno-sign-conversion)
53 add_compile_options(-Werror=maybe-uninitialized)
54 add_compile_options(-Werror=implicit-function-declaration)
55 add_compile_options(-ffunction-sections -fdata-sections)
56 add_compile_options(-fPIC)
57 add_compile_options(-g)
58
59 set(CMAKE_C_FLAGS_PROFILING    "-g -O2 -pg -Wp,-U_FORTIFY_SOURCE")
60 set(CMAKE_C_FLAGS_DEBUG        "-g -ggdb -Wp,-U_FORTIFY_SOURCE")
61 set(CMAKE_C_FLAGS_RELEASE      "-g -O2")
62 set(CMAKE_C_FLAGS_CCOV         "-g -O2 --coverage")
63
64 ###########################################################################
65
66 INCLUDE(FindThreads)
67 FIND_PACKAGE(Threads)
68
69 PKG_CHECK_MODULES(json-c REQUIRED json-c)
70
71 CHECK_INCLUDE_FILES(magic.h HAVE_MAGIC_H)
72 CHECK_LIBRARY_EXISTS(magic magic_load "" HAVE_LIBMAGIC_SO)
73 IF(HAVE_MAGIC_H)
74   IF(HAVE_LIBMAGIC_SO)
75     SET(HAVE_LIBMAGIC "1")
76   ENDIF(HAVE_LIBMAGIC_SO)
77 ENDIF(HAVE_MAGIC_H)
78
79 IF(NOT HAVE_LIBMAGIC)
80   MESSAGE(FATAL_ERROR "\"magic.h\" or \"libmagic.so\" missing.
81     Please install the \"file-devel\" or \"libmagic-dev\" package !")
82 ENDIF(NOT HAVE_LIBMAGIC)
83 ADD_DEFINITIONS(-DUSE_MAGIC_MIME_TYPE)
84
85 PKG_CHECK_MODULES(libsystemd REQUIRED libsystemd>=222)
86 PKG_CHECK_MODULES(libmicrohttpd REQUIRED libmicrohttpd>=0.9.55)
87 PKG_CHECK_MODULES(openssl REQUIRED openssl)
88 PKG_CHECK_MODULES(uuid REQUIRED uuid)
89 PKG_CHECK_MODULES(cynara cynara-client)
90
91 IF(AGL_DEVEL)
92         ADD_DEFINITIONS(-DAGL_DEVEL)
93 endif()
94
95 IF(cynara_FOUND)
96         ADD_DEFINITIONS(-DBACKEND_PERMISSION_IS_CYNARA)
97 ENDIF(cynara_FOUND)
98
99 ADD_DEFINITIONS(-DAFB_VERSION="${PROJECT_VERSION}")
100
101 INCLUDE_DIRECTORIES(
102         ${INCLUDE_DIRS}
103         ${CMAKE_SOURCE_DIR}/include
104         ${json-c_INCLUDE_DIRS}
105         ${libsystemd_INCLUDE_DIRS}
106         ${libmicrohttpd_INCLUDE_DIRS}
107         ${uuid_INCLUDE_DIRS}
108         ${openssl_INCLUDE_DIRS}
109         ${cynara_INCLUDE_DIRS}
110 )
111
112 SET(link_libraries
113         ${CMAKE_THREAD_LIBS_INIT}
114         ${json-c_LDFLAGS}
115         ${libsystemd_LDFLAGS}
116         ${libmicrohttpd_LDFLAGS}
117         ${uuid_LDFLAGS}
118         ${openssl_LDFLAGS}
119         ${cynara_LDFLAGS}
120         -lmagic
121         -ldl
122         -lrt
123         )
124
125 SET(binding_install_dir ${CMAKE_INSTALL_FULL_LIBDIR}/afb)
126
127 ###########################################################################
128 # activates the monitoring by default
129 if(INCLUDE_MONITORING)
130         add_definitions(-DWITH_MONITORING_OPTION)
131         INSTALL(DIRECTORY
132                 ${CMAKE_CURRENT_SOURCE_DIR}/test/monitoring
133                 DESTINATION
134                 ${binding_install_dir}
135         )
136 endif()
137
138 ###########################################################################
139
140 ADD_SUBDIRECTORY(src)
141 ADD_SUBDIRECTORY(include)
142 ADD_SUBDIRECTORY(bindings)
143
144 ############################################################
145 # installs the pkgconfig files
146 CONFIGURE_FILE(afb-daemon.pc.in afb-daemon.pc @ONLY)
147 CONFIGURE_FILE(libafbwsc.pc.in libafbwsc.pc @ONLY)
148
149 INSTALL(FILES
150     ${CMAKE_CURRENT_BINARY_DIR}/afb-daemon.pc
151     ${CMAKE_CURRENT_BINARY_DIR}/libafbwsc.pc
152     DESTINATION
153     ${CMAKE_INSTALL_LIBDIR}/pkgconfig
154     )
155