u16id: Add maps for identifiers id of 16 bits
[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         u16id.c
128         uuid.c
129         verbose.c
130         watchdog.c
131         websock.c
132         wrap-json.c
133 )
134
135 ADD_LIBRARY(afb-lib STATIC ${AFB_LIB_SOURCES})
136
137 ###########################################
138 # build and install afb-daemon
139 ###########################################
140 ADD_EXECUTABLE(afb-daemon main-afb-daemon.c)
141 TARGET_LINK_LIBRARIES(afb-daemon
142         afb-lib
143         ${link_libraries}
144 )
145 INSTALL(TARGETS afb-daemon
146         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
147
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
154                 afb-lib
155                 ${link_libraries}
156         )
157         INSTALL(TARGETS afs-supervisor
158                 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
159 ENDIF()
160
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}
170         ${json-c_LDFLAGS}
171         -lpthread
172         -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export-afbwsc.map
173         -Wl,--as-needed
174         -Wl,--gc-sections
175 )
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)
178
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
184         afbwsc
185         ${link_libraries}
186         ${libsystemd_LDFLAGS}
187 )
188 INSTALL(TARGETS afb-client-demo
189         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
190