cf978c95f7508af9eaa82da8720e52f3a6e39734
[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-error-text.c
92         afb-evt.c
93         afb-export.c
94         afb-fdev.c
95         afb-hook.c
96         afb-hook-flags.c
97         afb-hreq.c
98         afb-hsrv.c
99         afb-hswitch.c
100         afb-method.c
101         afb-monitor.c
102         afb-msg-json.c
103         afb-perm.c
104         afb-permission-text.c
105         afb-proto-ws.c
106         afb-session.c
107         afb-socket.c
108         afb-stub-ws.c
109         afb-supervision.c
110         afb-token.c
111         afb-trace.c
112         afb-websock.c
113         afb-ws-client.c
114         afb-ws-json1.c
115         afb-ws.c
116         afb-wsj1.c
117         afb-xreq.c
118         evmgr.c
119         fdev.c
120         fdev-epoll.c
121         fdev-systemd.c
122         globset.c
123         jobs.c
124         locale-root.c
125         pearson.c
126         process-name.c
127         sig-monitor.c
128         subpath.c
129         systemd.c
130         u16id.c
131         uuid.c
132         verbose.c
133         watchdog.c
134         websock.c
135         wrap-json.c
136 )
137
138 ADD_LIBRARY(afb-lib STATIC ${AFB_LIB_SOURCES})
139
140 ###########################################
141 # build and install afb-daemon
142 ###########################################
143 ADD_EXECUTABLE(afb-daemon main-afb-daemon.c)
144 TARGET_LINK_LIBRARIES(afb-daemon
145         afb-lib
146         ${link_libraries}
147 )
148 INSTALL(TARGETS afb-daemon
149         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
150
151 ###########################################
152 # build and install afb-daemon
153 ###########################################
154 IF(INCLUDE_SUPERVISOR)
155         ADD_EXECUTABLE(afs-supervisor main-afs-supervisor.c afs-supervisor.c afs-discover.c afs-args.c)
156         TARGET_LINK_LIBRARIES(afs-supervisor
157                 afb-lib
158                 ${link_libraries}
159         )
160         INSTALL(TARGETS afs-supervisor
161                 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
162 ENDIF()
163
164 ###########################################
165 # build and install libafbwsc
166 ###########################################
167 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)
168 SET_TARGET_PROPERTIES(afbwsc PROPERTIES
169         VERSION ${LIBAFBWSC_VERSION}
170         SOVERSION ${LIBAFBWSC_SOVERSION})
171 TARGET_LINK_LIBRARIES(afbwsc
172         ${libsystemd_LDFLAGS}
173         ${json-c_LDFLAGS}
174         -lpthread
175         -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export-afbwsc.map
176         -Wl,--as-needed
177         -Wl,--gc-sections
178 )
179 INSTALL(TARGETS afbwsc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
180 INSTALL(FILES afb-wsj1.h afb-ws-client.h afb-proto-ws.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/afb)
181
182 ###########################################
183 # build and install afb-client-demo
184 ###########################################
185 ADD_EXECUTABLE(afb-client-demo main-afb-client-demo.c)
186 TARGET_LINK_LIBRARIES(afb-client-demo
187         afbwsc
188         ${link_libraries}
189         ${libsystemd_LDFLAGS}
190 )
191 INSTALL(TARGETS afb-client-demo
192         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
193