• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# libwebsockets - small server side websockets and web server implementation
3#
4# Copyright (C) 2010 - 2020 Andy Green <andy@warmcat.com>
5#
6# Permission is hereby granted, free of charge, to any person obtaining a copy
7# of this software and associated documentation files (the "Software"), to
8# deal in the Software without restriction, including without limitation the
9# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10# sell copies of the Software, and to permit persons to whom the Software is
11# furnished to do so, subject to the following conditions:
12#
13# The above copyright notice and this permission notice shall be included in
14# all copies or substantial portions of the Software.
15#
16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22# IN THE SOFTWARE.
23#
24# This part of the CMakeLists.txt defines internal logic between options
25
26if(IOS)
27    set(LWS_DETECTED_PLAT_IOS 1)
28endif()
29
30# Workaround for ESP-IDF
31# Detect ESP_PLATFORM environment flag, if exist, set LWS_WITH_ESP32.
32# Otherwise the user may not be able to run configuration ESP-IDF in the first time.
33if (ESP_PLATFORM)
34	message(STATUS "ESP-IDF enabled")
35	set(LWS_WITH_ESP32 ON)
36	set(LWS_WITH_ZLIB OFF)
37	set(LWS_HAVE_mbedtls_ssl_get_alpn_protocol 1)
38else()
39	set(LWS_WITH_ESP32_HELPER OFF)
40endif()
41
42if (LWS_WITH_ESP32)
43	set(LWS_PLAT_FREERTOS 1)
44endif()
45
46if (LWS_PLAT_OPTEE)
47	set(LWS_WITH_UDP 0)
48endif()
49
50if (LWS_PLAT_FREERTOS OR (${CMAKE_SYSTEM_NAME} MATCHES "QNX"))
51	message(STATUS "No LWS_WITH_DIR or LWS_WITH_LEJP_CONF")
52	set(LWS_WITH_DIR OFF)
53	set(LWS_WITH_LEJP_CONF OFF)
54	message("LWS_WITH_DIR ${LWS_WITH_DIR}")
55else()
56	message(STATUS "Compiled with LWS_WITH_DIR and LWS_WITH_LEJP_CONF")
57	set(LWS_WITH_DIR ON)
58	set(LWS_WITH_LEJP_CONF ON)
59endif()
60
61if (LWS_FOR_GITOHASHI)
62	set(LWS_WITH_THREADPOOL 1)
63	set(LWS_WITH_HTTP2 1)
64	set(LWS_UNIX_SOCK 1)
65	set(LWS_WITH_HTTP_PROXY 1)
66	set(LWS_WITH_FTS 1)
67	set(LWS_WITH_DISKCACHE 1)
68	set(LWS_WITH_LWSAC 1)
69	set(LWS_WITH_LEJP_CONF 1)
70	set(LWS_WITH_SPAWN 1)
71	set(LWS_WITH_FSMOUNT 1)
72	set(LWS_WITH_STRUCT_JSON 1)
73	set(LWS_WITH_STRUCT_SQLITE3 1)
74endif()
75
76if(LWS_WITH_DISTRO_RECOMMENDED)
77	set(LWS_WITH_HTTP2 1)				# selfcontained
78	set(LWS_WITH_LWSWS 1)				# libuv
79	set(LWS_WITH_CGI 1)				# selfcontained
80	set(LWS_WITH_HTTP_STREAM_COMPRESSION 1)		# libz and brotli if avail
81	set(LWS_IPV6 1)					# selfcontained
82	set(LWS_WITH_ZIP_FOPS 1)			# libz
83	set(LWS_WITH_SOCKS5 1)				# selfcontained
84	set(LWS_WITH_RANGES 1)				# selfcontained
85	set(LWS_WITH_ACME 1)				# selfcontained / tls
86	set(LWS_WITH_SYS_METRICS 1)			# selfcontained
87	set(LWS_WITH_GLIB 1)				# glib
88	set(LWS_WITH_LIBUV 1)				# libuv
89	set(LWS_WITH_LIBEV 1)				# libev
90	set(LWS_WITH_LIBEVENT 1)			# libevent
91	set(LWS_WITH_EVLIB_PLUGINS 1)			# event libraries created as plugins / individual packages
92	set(LWS_WITHOUT_EXTENSIONS 0)			# libz
93	set(LWS_ROLE_DBUS 1)				# dbus-related libs
94	set(LWS_WITH_FTS 1)				# selfcontained
95	set(LWS_WITH_THREADPOOL 1)			# pthreads
96	set(LWS_UNIX_SOCK 1)				# selfcontained
97	set(LWS_WITH_HTTP_PROXY 1)			# selfcontained
98	set(LWS_WITH_DISKCACHE 1)			# selfcontained
99	set(LWS_WITH_LWSAC 1)				# selfcontained
100	set(LWS_WITH_LEJP_CONF 1)			# selfcontained
101	set(LWS_WITH_PLUGINS_BUILTIN 1)			# selfcontained
102	set(LWS_ROLE_RAW_PROXY 1)			# selfcontained
103	set(LWS_WITH_GENCRYPTO 1)			# selfcontained / tls
104	set(LWS_WITH_CBOR 1)				# selfcontained
105	set(LWS_WITH_COSE 1)				# selfcontained
106	set(LWS_WITH_JOSE 1)				# selfcontained
107	set(LWS_WITH_STRUCT_JSON 1)			# selfcontained
108	set(LWS_WITH_STRUCT_SQLITE3 1)			# sqlite3
109	set(LWS_WITH_SPAWN 1)				# selfcontained
110# libmount is problematic on Centos 8 / RHEL 8
111#	set(LWS_WITH_FSMOUNT 1)
112	set(LWS_ROLE_MQTT 1)				# selfcontained
113	set(LWS_WITH_SECURE_STREAMS 1)			# selfcontained
114	set(LWS_WITH_SECURE_STREAMS_PROXY_API 1)	# selfcontained
115	set(LWS_WITH_DIR 1)				# selfcontained
116endif()
117
118# LWS_WITH_EVENT_LIBS is set if any event lib selected
119
120if (LWS_WITH_LIBEV OR
121    LWS_WITH_LIBUV OR
122    LWS_WITH_LIBEVENT OR
123    LWS_WITH_GLIB OR
124    LWS_WITH_SDEVENT OR
125    LWS_WITH_ULOOP)
126	set(LWS_WITH_EVENT_LIBS 1)
127else()
128	unset(LWS_WITH_EVENT_LIBS)
129endif()
130
131if (LWS_WITH_SECURE_STREAMS_PROXY_API)
132	set(LWS_WITH_LWS_DSH 1)
133	set(LWS_WITH_UNIX_SOCK 1)
134	set(LWS_WITH_SYS_SMD 1)
135endif()
136
137if (NOT LWS_WITH_NETWORK)
138	set(LWS_ROLE_MQTT 0)
139	set(LWS_ROLE_H1 0)
140	set(LWS_ROLE_WS 0)
141	set(LWS_ROLE_RAW 0)
142	set(LWS_WITHOUT_EXTENSIONS 1)
143	set(LWS_WITHOUT_SERVER 1)
144	set(LWS_WITHOUT_CLIENT 1)
145	set(LWS_WITH_HTTP2 0)
146	set(LWS_WITH_SOCKS5 0)
147	set(LWS_UNIX_SOCK 0)
148	set(LWS_WITH_HTTP_PROXY 0)
149	set(LWS_WITH_PLUGINS 0)
150	set(LWS_WITH_LWSWS 0)
151	set(LWS_WITH_CGI 0)
152	set(LWS_ROLE_RAW_PROXY 0)
153	set(LWS_WITH_PEER_LIMITS 0)
154	set(LWS_WITH_HTTP_STREAM_COMPRESSION 0)
155	set(LWS_WITH_HTTP_BROTLI 0)
156	set(LWS_WITH_POLL 0)
157	set(LWS_WITH_SEQUENCER 0)
158	set(LWS_ROLE_DBUS 0)
159	set(LWS_WITH_LWS_DSH 0)
160	set(LWS_WITH_THREADPOOL 0)
161	set(LWS_WITH_SYS_SMD 0)
162endif()
163
164if (LWS_WITH_CGI)
165	set(LWS_WITH_SPAWN 1)
166endif()
167
168if (LWS_WITH_STRUCT_SQLITE3)
169	set(LWS_WITH_SQLITE3 1)
170endif()
171
172if (LWS_WITH_HTTP_BASIC_AUTH)
173	# WWW_AUTHENTICATE used by basic auth is an "uncommon header"
174	set(LWS_WITH_HTTP_UNCOMMON_HEADERS 1)
175endif()
176
177if (LWS_WITH_SECURE_STREAMS_AUTH_SIGV4)
178	set(LWS_WITH_GENCRYPTO 1)
179endif()
180
181if (APPLE)
182	set(LWS_ROLE_DBUS 0)
183endif()
184
185if(NOT DEFINED CMAKE_BUILD_TYPE)
186	set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type")
187endif()
188
189if (LWS_PLAT_FREERTOS)
190	set(LWS_UNIX_SOCK 0)
191endif()
192
193if (LWS_PLAT_FREERTOS)
194	set(LWS_WITH_FTS 0)
195endif()
196
197if (LWS_WITH_HTTP2)
198	set(LWS_ROLE_H2 1)
199endif()
200if (LWS_WITH_CGI)
201	set(LWS_ROLE_CGI 1)
202endif()
203
204if (NOT LWS_ROLE_WS)
205	set(LWS_WITHOUT_EXTENSIONS 1)
206endif()
207
208unset(LWS_WITH_LIBUV_INTERNAL)
209
210if (LWS_WITH_LWSWS)
211 message(STATUS "LWS_WITH_LWSWS --> Enabling LWS_WITH_PLUGINS and LWS_WITH_LIBUV")
212 set(LWS_WITH_PLUGINS 1)
213 set(LWS_WITH_LIBUV 1)
214 set(LWS_WITH_LIBUV_INTERNAL 1)
215 set(LWS_WITH_EVENT_LIBS 1) # implied by LIBUV_INTERNAL
216 set(LWS_WITH_ACCESS_LOG 1)
217 set(LWS_WITH_SYS_METRICS 1)
218 set(LWS_WITH_LEJP 1)
219 set(LWS_WITH_LEJP_CONF 1)
220 set(LWS_WITH_PEER_LIMITS 1)
221 set(LWS_ROLE_RAW_PROXY 1)
222endif()
223
224# sshd plugin
225if (LWS_WITH_PLUGINS)
226 set(LWS_WITH_GENCRYPTO 1)
227endif()
228
229if (LWS_ROLE_RAW_PROXY)
230 set (LWS_WITH_CLIENT 1)
231 set (LWS_WITH_SERVER 1)
232endif()
233
234if (LWS_WITH_ACME)
235 set (LWS_WITH_CLIENT 1)
236 set (LWS_WITH_SERVER 1)
237 set (LWS_WITH_JOSE 1)
238endif()
239
240if (LWS_WITH_JOSE)
241 set(LWS_WITH_LEJP 1)
242 set(LWS_WITH_GENCRYPTO 1)
243endif()
244
245if (LWS_WITH_PLUGINS AND NOT LWS_WITH_LIBUV)
246message(STATUS "LWS_WITH_PLUGINS --> Enabling LWS_WITH_LIBUV")
247 set(LWS_WITH_LIBUV 1)
248 set(LWS_WITH_EVENT_LIBS 1)
249endif()
250
251if (LWS_WITH_PLUGINS OR LWS_WITH_CGI)
252	# sshd plugin
253 set(LWS_WITH_GENCRYPTO 1)
254endif()
255
256if (LWS_PLAT_FREERTOS)
257 set(LWS_WITH_SHARED OFF)
258 if (LWS_WITH_SSL)
259  set(LWS_WITH_MBEDTLS ON)
260 endif()
261  # set(LWS_WITHOUT_CLIENT ON)
262 set(LWS_WITHOUT_TESTAPPS ON)
263 set(LWS_WITHOUT_EXTENSIONS ON)
264 set(LWS_WITH_PLUGINS OFF)
265 set(LWS_WITH_RANGES ON)
266 # this implies no pthreads in the lib
267 set(LWS_MAX_SMP 1)
268 set(LWS_HAVE_MALLOC 1)
269 set(LWS_HAVE_REALLOC 1)
270 set(LWS_HAVE_GETIFADDRS 1)
271 set(LWS_WITH_CUSTOM_HEADERS 0)
272endif()
273
274#if (LWS_WITH_ESP32)
275# set(LWS_WITH_ZIP_FOPS 1)
276#endif()
277
278if (WIN32)
279#set(LWS_MAX_SMP 1)
280if (LWS_WITH_PLUGINS)
281set(LWS_WITH_LIBUV_INTERNAL 1)
282endif()
283endif()
284
285if (LWS_WITHOUT_SERVER)
286set(LWS_WITH_LWSWS OFF)
287endif()
288
289if (LWS_WITH_LEJP_CONF)
290	set(LWS_WITH_DIR 1)
291endif()
292
293# confirm H1 relationships
294
295if (NOT LWS_ROLE_H1 AND LWS_ROLE_H2)
296	message(FATAL_ERROR "H2 requires LWS_ROLE_H1")
297endif()
298
299if (NOT LWS_ROLE_H1 AND LWS_ROLE_WS)
300	message(FATAL_ERROR "WS requires LWS_ROLE_H1")
301endif()
302
303if (NOT LWS_ROLE_H1 AND LWS_ROLE_CGI)
304	message(FATAL_ERROR "CGI requires LWS_ROLE_H1")
305endif()
306
307# confirm HTTP relationships
308
309if (NOT LWS_ROLE_H1 AND NOT LWS_ROLE_H2 AND LWS_WITH_HTTP_PROXY)
310	message(FATAL_ERROR "LWS_WITH_LWSWS requires LWS_ROLE_H1")
311endif()
312
313if (NOT LWS_ROLE_H1 AND NOT LWS_ROLE_H2 AND LWS_WITH_HTTP_PROXY)
314	message(FATAL_ERROR "LWS_WITH_HTTP_PROXY requires LWS_ROLE_H1")
315endif()
316
317if (NOT LWS_ROLE_H1 AND NOT LWS_ROLE_H2 AND LWS_WITH_RANGES)
318	message(FATAL_ERROR "LWS_WITH_RANGES requires LWS_ROLE_H1")
319endif()
320
321if (NOT LWS_ROLE_H1 AND NOT LWS_ROLE_H2 AND LWS_WITH_ACCESS_LOG)
322	message(FATAL_ERROR "LWS_WITH_ACCESS_LOG requires LWS_ROLE_H1")
323endif()
324
325if (LWS_WITH_HTTP_PROXY AND (LWS_WITHOUT_CLIENT OR LWS_WITHOUT_SERVER))
326	message("You have to enable both client and server for http proxy")
327	set(LWS_WITH_HTTP_PROXY 0)
328endif()
329
330if (NOT LWS_WITHOUT_EXTENSIONS OR LWS_WITH_ZIP_FOPS)
331	set(LWS_WITH_ZLIB 1)
332endif()
333
334if (LWS_WITH_SECURE_STREAMS)
335	set(LWS_WITH_SECURE_STREAMS_SYS_AUTH_API_AMAZON_COM 1)
336endif()
337
338if (NOT (LWS_WITH_STATIC OR LWS_WITH_SHARED))
339	message(FATAL_ERROR "Makes no sense to compile with neither static nor shared libraries.")
340endif()
341
342if (LWS_WITHOUT_DAEMONIZE OR WIN32)
343	set(LWS_NO_DAEMONIZE 1)
344endif()
345
346if (LWS_IPV6)
347	set(LWS_WITH_IPV6 1)
348endif()
349
350if (LWS_UNIX_SOCK)
351    set(LWS_WITH_UNIX_SOCK 1)
352endif()
353
354if (NOT LWS_MAX_SMP)
355	set(LWS_MAX_SMP 1)
356endif()
357if ("${LWS_MAX_SMP}" STREQUAL "")
358	set(LWS_MAX_SMP 1)
359endif()
360
361set(LWS_WITH_CLIENT 1)
362if (LWS_WITHOUT_CLIENT)
363	set(LWS_WITH_CLIENT)
364	set(LWS_WITH_SECURE_STREAMS 0)
365endif()
366set(LWS_WITH_SERVER 1)
367if (LWS_WITHOUT_SERVER)
368	set(LWS_WITH_SERVER)
369endif()
370
371# using any abstract protocol enables LWS_WITH_ABSTRACT
372
373#if (LWS_WITH_SMTP)
374#	set(LWS_WITH_ABSTRACT 1)
375#endif()
376
377if (NOT LWS_WITH_EVLIB_PLUGINS AND (LWS_WITH_LIBEV AND LWS_WITH_LIBEVENT))
378	message(FATAL_ERROR "Sorry libev and libevent conflict with each others' namespace, you can only have one or the other")
379endif()
380
381if (LWS_SSL_SERVER_WITH_ECDH_CERT)
382	set(LWS_SSL_SERVER_WITH_ECDH_CERT 1)
383endif()
384
385# LWS_OPENSSL_SUPPORT deprecated... use LWS_WITH_TLS
386if (LWS_WITH_SSL OR LWS_WITH_MBEDTLS)
387	set(LWS_OPENSSL_SUPPORT 1)
388	set(LWS_WITH_TLS 1)
389endif()
390
391if (NOT LWS_WITH_SSL)
392	set(LWS_WITHOUT_BUILTIN_SHA1 OFF)
393endif()
394# protocol plugins dont make any sense either
395if (LWS_WITH_PLUGINS AND NOT LWS_WITH_SHARED)
396	message("Deselecting PLUGINS since building static")
397	set(LWS_WITH_PLUGINS 0)
398endif()
399
400if (LWS_WITH_TLS_SESSIONS)
401	if (NOT LWS_WITH_NETWORK OR NOT LWS_WITH_CLIENT)
402		message("TLS_SESSIONS support requires client, disabling")
403		set(LWS_WITH_TLS_SESSIONS OFF)
404	endif()
405endif()
406
407# if we're only building static, we don't want event lib plugins
408#
409if (LWS_WITH_EVLIB_PLUGINS AND NOT LWS_WITH_SHARED)
410	message("Deselecting EVLIB_PLUGINS since building static")
411	set(LWS_WITH_EVLIB_PLUGINS 0)
412endif()
413
414if (LWS_WITH_PLUGINS OR (LWS_WITH_EVLIB_PLUGINS AND LWS_WITH_EVENT_LIBS))
415	set(LWS_WITH_PLUGINS_API 1)
416endif()
417
418if (WIN32 AND NOT LWS_EXT_PTHREAD_LIBRARIES)
419        set(LWS_MAX_SMP 1)
420        message("SMD requires pthreads")
421        set(LWS_WITH_SYS_SMD 0)
422endif()
423
424