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 if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9)
20 message(FATAL_ERROR "Require at least gcc-4.9")
21 endif(CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9)
23 ADD_DEFINITIONS(-DINTRINSIC_BINDING_DIR="${INTRINSIC_BINDING_DIR}")
24 # Always add INFER_EXTENSION (more details in afb-hreq.c)
25 ADD_DEFINITIONS(-DINFER_EXTENSION)
27 ############################################################################
28 # TODO: improve below setting by using config file
29 option(WITH_SIG_MONITOR_DUMPSTACK "Activate dump stack on error" ON)
30 option(WITH_SIG_MONITOR_SIGNALS "Activate handling of signals" ON)
31 option(WITH_SIG_MONITOR_FOR_CALL "Activate monitoring of calls" ON)
32 option(WITH_SIG_MONITOR_TIMERS "Activate monitoring of call expiration" ON)
33 option(WITH_AFB_HOOK "Include hooking" ON)
34 option(WITH_AFB_TRACE "Include monitoring trace" ON)
35 option(WITH_SUPERVISOR "Activates installation of supervisor" OFF)
36 option(WITH_DBUS_TRANSPARENCY "Allows API transparency over DBUS" OFF)
37 option(WITH_LEGACY_BINDING_V1 "Includes the legacy Binding API version 1" OFF)
38 option(WITH_LEGACY_BINDING_V2 "Includes the legacy Binding API version 2" ON)
39 option(WITH_LEGACY_BINDING_VDYN "Includes the legacy Binding API version dynamic" OFF)
40 option(WITH_DYNAMIC_BINDING "Allow to load dynamic bindings (shared libraries)" ON)
42 if(INCLUDE_SUPERVISOR)
43 set(WITH_SUPERVISOR ON)
45 if(INCLUDE_DBUS_TRANSPARENCY)
46 set(WITH_DBUS_TRANSPARENCY ON)
48 if(INCLUDE_LEGACY_BINDING_V1)
49 set(WITH_LEGACY_BINDING_V1 ON)
51 if(INCLUDE_LEGACY_BINDING_VDYN)
52 set(WITH_LEGACY_BINDING_VDYN ON)
56 -DAGL_DEVEL=$<BOOL:${AGL_DEVEL}>
57 -DWITH_SIG_MONITOR_DUMPSTACK=$<BOOL:${WITH_SIG_MONITOR_DUMPSTACK}>
58 -DWITH_SIG_MONITOR_SIGNALS=$<BOOL:${WITH_SIG_MONITOR_SIGNALS}>
59 -DWITH_SIG_MONITOR_FOR_CALL=$<BOOL:${WITH_SIG_MONITOR_FOR_CALL}>
60 -DWITH_SIG_MONITOR_TIMERS=$<BOOL:${WITH_SIG_MONITOR_TIMERS}>
61 -DWITH_AFB_HOOK=$<BOOL:${WITH_AFB_HOOK}>
62 -DWITH_AFB_TRACE=$<BOOL:${WITH_AFB_TRACE}>
63 -DWITH_LEGACY_BINDING_V1=$<BOOL:${INCLUDE_LEGACY_BINDING_V1}>
64 -DWITH_LEGACY_BINDING_V2=$<BOOL:${WITH_LEGACY_BINDING_V2}>
65 -DWITH_LEGACY_BINDING_VDYN=$<BOOL:${INCLUDE_LEGACY_BINDING_VDYN}>
66 -DWITH_DBUS_TRANSPARENCY=$<BOOL:${INCLUDE_DBUS_TRANSPARENCY}>
67 -DWITH_SUPERVISION=$<BOOL:${INCLUDE_SUPERVISOR}>
68 -DWITH_DYNAMIC_BINDING=$<BOOL:${WITH_DYNAMIC_BINDING}>
70 ############################################################################
135 ADD_LIBRARY(afb-lib STATIC ${AFB_LIB_SOURCES})
137 ###########################################
138 # build and install afb-daemon
139 ###########################################
140 ADD_EXECUTABLE(afb-daemon main-afb-daemon.c)
141 TARGET_LINK_LIBRARIES(afb-daemon
145 INSTALL(TARGETS afb-daemon
146 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
148 ###########################################
149 # build and install afb-daemon
150 ###########################################
151 IF(INCLUDE_SUPERVISOR)
152 ADD_EXECUTABLE(afs-supervisor main-afs-supervisor.c afs-supervisor.c afs-discover.c afs-args.c)
153 TARGET_LINK_LIBRARIES(afs-supervisor
157 INSTALL(TARGETS afs-supervisor
158 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
161 ###########################################
162 # build and install libafbwsc
163 ###########################################
164 ADD_LIBRARY(afbwsc SHARED afb-ws.c afb-ws-client.c afb-wsj1.c websock.c afb-proto-ws.c fdev.c fdev-systemd.c verbose.c)
165 SET_TARGET_PROPERTIES(afbwsc PROPERTIES
166 VERSION ${LIBAFBWSC_VERSION}
167 SOVERSION ${LIBAFBWSC_SOVERSION})
168 TARGET_LINK_LIBRARIES(afbwsc
169 ${libsystemd_LDFLAGS}
172 -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export-afbwsc.map
176 INSTALL(TARGETS afbwsc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
177 INSTALL(FILES afb-wsj1.h afb-ws-client.h afb-proto-ws.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/afb)
179 ###########################################
180 # build and install afb-client-demo
181 ###########################################
182 ADD_EXECUTABLE(afb-client-demo main-afb-client-demo.c)
183 TARGET_LINK_LIBRARIES(afb-client-demo
186 ${libsystemd_LDFLAGS}
188 INSTALL(TARGETS afb-client-demo
189 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})