Introduce object for tokens
[src/app-framework-binder.git] / src / CMakeLists.txt
1 ###########################################################################
2 # Copyright (C) 2015-2019 "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 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)
22
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)
26
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)
41
42 if(INCLUDE_SUPERVISOR)
43   set(WITH_SUPERVISOR ON)
44 endif()
45 if(INCLUDE_DBUS_TRANSPARENCY)
46   set(WITH_DBUS_TRANSPARENCY ON)
47 endif()
48 if(INCLUDE_LEGACY_BINDING_V1)
49   set(WITH_LEGACY_BINDING_V1 ON)
50 endif()
51 if(INCLUDE_LEGACY_BINDING_VDYN)
52   set(WITH_LEGACY_BINDING_VDYN ON)
53 endif()
54
55 add_definitions(
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}>
69 )
70 ############################################################################
71
72 SET(AFB_LIB_SOURCES
73         afb-api.c
74         afb-api-dbus.c
75         afb-api-so.c
76         afb-api-so-v1.c
77         afb-api-so-v2.c
78         afb-api-so-v3.c
79         afb-api-so-vdyn.c
80         afb-api-v3.c
81         afb-api-ws.c
82         afb-apiset.c
83         afb-args.c
84         afb-auth.c
85         afb-autoset.c
86         afb-calls.c
87         afb-common.c
88         afb-context.c
89         afb-cred.c
90         afb-debug.c
91         afb-evt.c
92         afb-export.c
93         afb-fdev.c
94         afb-hook.c
95         afb-hook-flags.c
96         afb-hreq.c
97         afb-hsrv.c
98         afb-hswitch.c
99         afb-method.c
100         afb-monitor.c
101         afb-msg-json.c
102         afb-proto-ws.c
103         afb-session.c
104         afb-socket.c
105         afb-stub-ws.c
106         afb-supervision.c
107         afb-token.c
108         afb-trace.c
109         afb-websock.c
110         afb-ws-client.c
111         afb-ws-json1.c
112         afb-ws.c
113         afb-wsj1.c
114         afb-xreq.c
115         evmgr.c
116         fdev.c
117         fdev-epoll.c
118         fdev-systemd.c
119         globset.c
120         jobs.c
121         locale-root.c
122         pearson.c
123         process-name.c
124         sig-monitor.c
125         subpath.c
126         systemd.c
127         uuid.c
128         verbose.c
129         watchdog.c
130         websock.c
131         wrap-json.c
132 )
133
134 ADD_LIBRARY(afb-lib STATIC ${AFB_LIB_SOURCES})
135
136 ###########################################
137 # build and install afb-daemon
138 ###########################################
139 ADD_EXECUTABLE(afb-daemon main-afb-daemon.c)
140 TARGET_LINK_LIBRARIES(afb-daemon
141         afb-lib
142         ${link_libraries}
143 )
144 INSTALL(TARGETS afb-daemon
145         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
146
147 ###########################################
148 # build and install afb-daemon
149 ###########################################
150 IF(INCLUDE_SUPERVISOR)
151         ADD_EXECUTABLE(afs-supervisor main-afs-supervisor.c afs-supervisor.c afs-discover.c afs-args.c)
152         TARGET_LINK_LIBRARIES(afs-supervisor
153                 afb-lib
154                 ${link_libraries}
155         )
156         INSTALL(TARGETS afs-supervisor
157                 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
158 ENDIF()
159
160 ###########################################
161 # build and install libafbwsc
162 ###########################################
163 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)
164 SET_TARGET_PROPERTIES(afbwsc PROPERTIES
165         VERSION ${LIBAFBWSC_VERSION}
166         SOVERSION ${LIBAFBWSC_SOVERSION})
167 TARGET_LINK_LIBRARIES(afbwsc
168         ${libsystemd_LDFLAGS}
169         ${json-c_LDFLAGS}
170         -lpthread
171         -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export-afbwsc.map
172         -Wl,--as-needed
173         -Wl,--gc-sections
174 )
175 INSTALL(TARGETS afbwsc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
176 INSTALL(FILES afb-wsj1.h afb-ws-client.h afb-proto-ws.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/afb)
177
178 ###########################################
179 # build and install afb-client-demo
180 ###########################################
181 ADD_EXECUTABLE(afb-client-demo main-afb-client-demo.c)
182 TARGET_LINK_LIBRARIES(afb-client-demo
183         afbwsc
184         ${link_libraries}
185         ${libsystemd_LDFLAGS}
186 )
187 INSTALL(TARGETS afb-client-demo
188         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
189