sig-monitor: Add compiling switches
[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(-DBINDING_INSTALL_DIR="${binding_install_dir}")
24 # Always add INFER_EXTENSION (more details in afb-hreq.c)
25 ADD_DEFINITIONS(-DINFER_EXTENSION)
26
27 ############################################################################
28 # TODO: improve below setting
29 set(USE_SIG_MONITOR_DUMPSTACK ON CACHE BOOL "activate dump stack on error")
30 set(USE_SIG_MONITOR_SIGNALS   ON CACHE BOOL "activate handling of signals")
31 set(USE_SIG_MONITOR_FOR_CALL  ON CACHE BOOL "activate monitoring of calls")
32 set(USE_SIG_MONITOR_TIMERS    ON CACHE BOOL "activate monitoring of call expiration")
33
34 if(USE_SIG_MONITOR_DUMPSTACK)
35   add_definitions(-DUSE_SIG_MONITOR_DUMPSTACK=1)
36 else()
37   add_definitions(-DUSE_SIG_MONITOR_DUMPSTACK=0)
38 endif()
39 if(USE_SIG_MONITOR_SIGNALS)
40   add_definitions(-DUSE_SIG_MONITOR_SIGNALS=1)
41 else()
42   add_definitions(-DUSE_SIG_MONITOR_SIGNALS=0)
43 endif()
44 if(USE_SIG_MONITOR_FOR_CALL)
45   add_definitions(-DUSE_SIG_MONITOR_FOR_CALL=1)
46 else()
47   add_definitions(-DUSE_SIG_MONITOR_FOR_CALL=0)
48 endif()
49 if(USE_SIG_MONITOR_TIMERS)
50   add_definitions(-DUSE_SIG_MONITOR_TIMERS=1)
51 else()
52   add_definitions(-DUSE_SIG_MONITOR_TIMERS=0)
53 endif()
54 ############################################################################
55
56 SET(AFB_LIB_SOURCES
57         afb-api.c
58         afb-api-so.c
59         afb-api-so-v2.c
60         afb-api-so-v3.c
61         afb-api-so-vdyn.c
62         afb-api-v3.c
63         afb-api-ws.c
64         afb-apiset.c
65         afb-auth.c
66         afb-autoset.c
67         afb-calls.c
68         afb-common.c
69         afb-config.c
70         afb-context.c
71         afb-cred.c
72         afb-debug.c
73         afb-evt.c
74         afb-export.c
75         afb-fdev.c
76         afb-hook.c
77         afb-hook-flags.c
78         afb-hreq.c
79         afb-hsrv.c
80         afb-hswitch.c
81         afb-method.c
82         afb-monitor.c
83         afb-msg-json.c
84         afb-proto-ws.c
85         afb-session.c
86         afb-socket.c
87         afb-stub-ws.c
88         afb-trace.c
89         afb-websock.c
90         afb-ws-client.c
91         afb-ws-json1.c
92         afb-ws.c
93         afb-wsj1.c
94         afb-xreq.c
95         evmgr.c
96         fdev.c
97         fdev-epoll.c
98         fdev-systemd.c
99         globset.c
100         jobs.c
101         locale-root.c
102         pearson.c
103         process-name.c
104         sig-monitor.c
105         subpath.c
106         systemd.c
107         verbose.c
108         watchdog.c
109         websock.c
110         wrap-json.c
111 )
112
113 IF(INCLUDE_LEGACY_BINDING_V1)
114         ADD_DEFINITIONS(-DWITH_LEGACY_BINDING_V1)
115         SET(AFB_LIB_SOURCES ${AFB_LIB_SOURCES} afb-api-so-v1.c)
116 ENDIF(INCLUDE_LEGACY_BINDING_V1)
117 IF(INCLUDE_LEGACY_BINDING_VDYN)
118         ADD_DEFINITIONS(-DWITH_LEGACY_BINDING_VDYN)
119         SET(AFB_LIB_SOURCES ${AFB_LIB_SOURCES} afb-api-so-vdyn.c)
120 ENDIF(INCLUDE_LEGACY_BINDING_VDYN)
121
122 IF(INCLUDE_DBUS_TRANSPARENCY)
123         ADD_DEFINITIONS(-DWITH_DBUS_TRANSPARENCY)
124         SET(AFB_LIB_SOURCES ${AFB_LIB_SOURCES} afb-api-dbus.c)
125 ENDIF()
126 IF(INCLUDE_SUPERVISOR)
127         ADD_DEFINITIONS(-DWITH_SUPERVISION)
128         SET(AFB_LIB_SOURCES ${AFB_LIB_SOURCES} afb-supervision.c)
129 ENDIF()
130
131 ADD_LIBRARY(afb-lib STATIC ${AFB_LIB_SOURCES})
132
133 ###########################################
134 # build and install afb-daemon
135 ###########################################
136 ADD_EXECUTABLE(afb-daemon main-afb-daemon.c)
137 TARGET_LINK_LIBRARIES(afb-daemon
138         afb-lib
139         ${link_libraries}
140 )
141 INSTALL(TARGETS afb-daemon
142         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
143
144 ###########################################
145 # build and install afb-daemon
146 ###########################################
147 IF(INCLUDE_SUPERVISOR)
148         ADD_EXECUTABLE(afs-supervisor main-afs-supervisor.c afs-supervisor.c afs-discover.c afs-config.c)
149         TARGET_LINK_LIBRARIES(afs-supervisor
150                 afb-lib
151                 ${link_libraries}
152         )
153         INSTALL(TARGETS afs-supervisor
154                 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
155 ENDIF()
156
157 ###########################################
158 # build and install libafbwsc
159 ###########################################
160 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)
161 SET_TARGET_PROPERTIES(afbwsc PROPERTIES
162         VERSION ${LIBAFBWSC_VERSION}
163         SOVERSION ${LIBAFBWSC_SOVERSION})
164 TARGET_LINK_LIBRARIES(afbwsc
165         ${libsystemd_LDFLAGS}
166         ${json-c_LDFLAGS}
167         -lpthread
168         -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export-afbwsc.map
169         -Wl,--as-needed
170         -Wl,--gc-sections
171 )
172 INSTALL(TARGETS afbwsc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
173 INSTALL(FILES afb-wsj1.h afb-ws-client.h afb-proto-ws.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/afb)
174
175 ###########################################
176 # build and install afb-client-demo
177 ###########################################
178 ADD_EXECUTABLE(afb-client-demo main-afb-client-demo.c)
179 TARGET_LINK_LIBRARIES(afb-client-demo
180         afbwsc
181         ${link_libraries}
182         ${libsystemd_LDFLAGS}
183 )
184 INSTALL(TARGETS afb-client-demo
185         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
186