forked from warmcat/libwebsockets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
2153 lines (1844 loc) · 66.7 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
cmake_minimum_required(VERSION 2.8.9)
# General Advice
#
# For selecting between DEBUG / RELEASE, use -DCMAKE_BUILD_TYPE=DEBUG or =RELEASE
# debug builds include source level debug info and extra logging
set(LWS_WITH_BUNDLED_ZLIB_DEFAULT OFF)
if(WIN32)
set(LWS_WITH_BUNDLED_ZLIB_DEFAULT ON)
endif()
#
# Select features recommended for PC distro packaging
#
option(LWS_WITH_DISTRO_RECOMMENDED "Enable features recommended for distro packaging" OFF)
#
# Major individual features
#
option(LWS_WITH_HTTP2 "Compile with server support for HTTP/2" OFF)
option(LWS_WITH_LWSWS "Libwebsockets Webserver" OFF)
option(LWS_WITH_CGI "Include CGI (spawn process with network-connected stdin/out/err) APIs" OFF)
option(LWS_IPV6 "Compile with support for ipv6" OFF)
option(LWS_UNIX_SOCK "Compile with support for UNIX domain socket" OFF)
option(LWS_WITH_PLUGINS "Support plugins for protocols and extensions" OFF)
option(LWS_WITH_HTTP_PROXY "Support for rewriting HTTP proxying (requires libhubbub)" OFF)
option(LWS_WITH_ZIP_FOPS "Support serving pre-zipped files" OFF)
option(LWS_WITH_SOCKS5 "Allow use of SOCKS5 proxy on client connections" OFF)
option(LWS_WITH_GENERIC_SESSIONS "With the Generic Sessions plugin" OFF)
option(LWS_WITH_PEER_LIMITS "Track peers and restrict resources a single peer can allocate" OFF)
option(LWS_WITH_ACCESS_LOG "Support generating Apache-compatible access logs" OFF)
option(LWS_WITH_RANGES "Support http ranges (RFC7233)" OFF)
option(LWS_WITH_SERVER_STATUS "Support json + jscript server monitoring" OFF)
option(LWS_WITH_ACME "Enable support for ACME automatic cert acquisition + maintenance (letsencrypt etc)" OFF)
#
# TLS library options... all except mbedTLS are basically OpenSSL variants.
#
option(LWS_WITH_SSL "Include SSL support (defaults to OpenSSL or similar, mbedTLS if LWS_WITH_MBEDTLS is set)" ON)
option(LWS_WITH_MBEDTLS "Use mbedTLS (>=2.0) replacement for OpenSSL. When setting this, you also may need to specify LWS_MBEDTLS_LIBRARIES and LWS_MBEDTLS_INCLUDE_DIRS" OFF)
option(LWS_WITH_BORINGSSL "Use BoringSSL replacement for OpenSSL" OFF)
option(LWS_WITH_CYASSL "Use CyaSSL replacement for OpenSSL. When setting this, you also need to specify LWS_CYASSL_LIBRARIES and LWS_CYASSL_INCLUDE_DIRS" OFF)
option(LWS_WITH_WOLFSSL "Use wolfSSL replacement for OpenSSL. When setting this, you also need to specify LWS_WOLFSSL_LIBRARIES and LWS_WOLFSSL_INCLUDE_DIRS" OFF)
option(LWS_SSL_CLIENT_USE_OS_CA_CERTS "SSL support should make use of the OS-installed CA root certs" ON)
#
# Event library options (may select multiple, or none for default poll()
#
option(LWS_WITH_LIBEV "Compile with support for libev" OFF)
option(LWS_WITH_LIBUV "Compile with support for libuv" OFF)
option(LWS_WITH_LIBEVENT "Compile with support for libevent" OFF)
#
# Static / Dynamic build options
#
option(LWS_WITH_STATIC "Build the static version of the library" ON)
option(LWS_WITH_SHARED "Build the shared version of the library" ON)
option(LWS_LINK_TESTAPPS_DYNAMIC "Link the test apps to the shared version of the library. Default is to link statically" OFF)
option(LWS_STATIC_PIC "Build the static version of the library with position-independent code" OFF)
#
# Specific platforms
#
option(LWS_WITH_ESP32 "Build for ESP32" OFF)
option(LWS_PLAT_OPTEE "Build for OPTEE" OFF)
#
# Client / Server / Test Apps build control
#
option(LWS_WITHOUT_CLIENT "Don't build the client part of the library" OFF)
option(LWS_WITHOUT_SERVER "Don't build the server part of the library" OFF)
option(LWS_WITHOUT_TESTAPPS "Don't build the libwebsocket-test-apps" OFF)
option(LWS_WITHOUT_TEST_SERVER "Don't build the test server" OFF)
option(LWS_WITHOUT_TEST_SERVER_EXTPOLL "Don't build the test server version that uses external poll" OFF)
option(LWS_WITHOUT_TEST_PING "Don't build the ping test application" OFF)
option(LWS_WITHOUT_TEST_ECHO "Don't build the echo test application" OFF)
option(LWS_WITHOUT_TEST_CLIENT "Don't build the client test application" OFF)
option(LWS_WITHOUT_TEST_FRAGGLE "Don't build the ping test application" OFF)
#
# Extensions (permessage-deflate)
#
option(LWS_WITHOUT_EXTENSIONS "Don't compile with extensions" ON)
option(LWS_WITH_ZLIB "Include zlib support (required for extensions)" OFF)
option(LWS_WITH_BUNDLED_ZLIB "Use bundled zlib version (Windows only)" ${LWS_WITH_BUNDLED_ZLIB_DEFAULT})
#
# Helpers + misc
#
option(LWS_WITHOUT_BUILTIN_GETIFADDRS "Don't use the BSD getifaddrs implementation from libwebsockets if it is missing (this will result in a compilation error) ... The default is to assume that your libc provides it. On some systems such as uclibc it doesn't exist." OFF)
option(LWS_FALLBACK_GETHOSTBYNAME "Also try to do dns resolution using gethostbyname if getaddrinfo fails" OFF)
option(LWS_WITHOUT_BUILTIN_SHA1 "Don't build the lws sha-1 (eg, because openssl will provide it" OFF)
option(LWS_WITH_LATENCY "Build latency measuring code into the library" OFF)
option(LWS_WITHOUT_DAEMONIZE "Don't build the daemonization api" ON)
option(LWS_SSL_SERVER_WITH_ECDH_CERT "Include SSL server use ECDH certificate" OFF)
option(LWS_WITH_LEJP "With the Lightweight JSON Parser" OFF)
option(LWS_WITH_LEJP_CONF "With LEJP configuration parser as used by lwsws" OFF)
option(LWS_WITH_SQLITE3 "Require SQLITE3 support" OFF)
option(LWS_WITH_SMTP "Provide SMTP support" OFF)
option(LWS_WITH_NO_LOGS "Disable all logging from being compiled in" OFF)
option(LWS_AVOID_SIGPIPE_IGN "Android 7+ reportedly needs this" OFF)
option(LWS_WITH_STATS "Keep statistics of lws internal operations" OFF)
option(LWS_WITH_JWS "JSON Web Signature (RFC7515) API" OFF)
option(LWS_WITH_GENHASH "Enable support for Generic Hash (SHA1 + SHA2 with api independent of TLS backend)" OFF)
option(LWS_WITH_GENRSA "Enable support for Generic RSA (RSA with api independent of TLS backend)" OFF)
option(LWS_WITH_SELFTESTS "Selftests run at context creation" OFF)
option(LWS_WITH_GCOV "Build with gcc gcov coverage instrumentation" OFF)
option(LWS_WITH_EXPORT_LWSTARGETS "Export libwebsockets CMake targets. Disable if they conflict with an outer cmake project." ON)
option(LWS_REPRODUCIBLE "Build libwebsockets reproducible. It removes the build user and hostname from the build" ON)
#
# End of user settings
#
if(LWS_WITH_DISTRO_RECOMMENDED)
set(LWS_WITH_HTTP2 1)
set(LWS_WITH_LWSWS 1)
set(LWS_WITH_CGI 1)
set(LWS_IPV6 1)
set(LWS_WITH_ZIP_FOPS 1)
set(LWS_WITH_SOCKS5 1)
set(LWS_WITH_RANGES 1)
set(LWS_WITH_ACME 1)
set(LWS_WITH_SERVER_STATUS 1)
set(LWS_WITH_LIBUV 1)
set(LWS_WITH_LIBEV 1)
set(LWS_WITH_LIBEVENT 1)
set(LWS_WITHOUT_EXTENSIONS 0)
endif()
if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type")
endif()
project(libwebsockets C)
set(PACKAGE "libwebsockets")
set(CPACK_PACKAGE_NAME "${PACKAGE}")
set(CPACK_PACKAGE_VERSION_MAJOR "2")
set(CPACK_PACKAGE_VERSION_MINOR "4")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_PACKAGE_VENDOR "[email protected]")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PACKAGE} ${PACKAGE_VERSION}")
set(SOVERSION "12")
if(NOT CPACK_GENERATOR)
if(UNIX)
set(CPACK_GENERATOR "TGZ")
else()
set(CPACK_GENERATOR "ZIP")
endif()
endif()
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
set(VERSION "${CPACK_PACKAGE_VERSION}")
set(LWS_LIBRARY_VERSION ${CPACK_PACKAGE_VERSION})
set(LWS_LIBRARY_VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR})
set(LWS_LIBRARY_VERSION_MINOR ${CPACK_PACKAGE_VERSION_MINOR})
set(LWS_LIBRARY_VERSION_PATCH ${CPACK_PACKAGE_VERSION_PATCH})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")
message(STATUS "CMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}'")
if(WIN32)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/win32port/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/win32port/version.rc @ONLY)
set(RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/win32port/version.rc)
endif()
# Try to find the current Git hash.
find_package(Git)
if(GIT_EXECUTABLE)
execute_process(
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND "${GIT_EXECUTABLE}" describe
OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(LWS_BUILD_HASH ${GIT_HASH})
# appen the build user and hostname
if(NOT LWS_REPRODUCIBLE)
execute_process(
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND "whoami"
OUTPUT_VARIABLE GIT_USER
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND "hostname"
OUTPUT_VARIABLE GIT_HOST
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(REGEX REPLACE "([^\\])[\\]([^\\])" "\\1\\\\\\\\\\2" GIT_USER ${GIT_USER})
set(LWS_BUILD_HASH ${GIT_USER}@${GIT_HOST}-${GIT_HASH})
endif()
message("Git commit hash: ${LWS_BUILD_HASH}")
endif()
if (LWS_WITH_LWSWS)
message(STATUS "LWS_WITH_LWSWS --> Enabling LWS_WITH_PLUGINS and LWS_WITH_LIBUV")
set(LWS_WITH_PLUGINS 1)
set(LWS_WITH_LIBUV 1)
set(LWS_WITH_ACCESS_LOG 1)
set(LWS_WITH_SERVER_STATUS 1)
set(LWS_WITH_LEJP 1)
set(LWS_WITH_LEJP_CONF 1)
set(LWS_WITH_PEER_LIMITS 1)
endif()
if (LWS_WITH_ACME)
set (LWS_WITHOUT_CLIENT 0)
set (LWS_WITHOUT_SERVER 0)
set (LWS_WITH_JWS 1)
endif()
if (LWS_WITH_JWS)
set(LWS_WITH_LEJP 1)
set(LWS_WITH_GENHASH 1)
set(LWS_WITH_GENRSA 1)
endif()
if (LWS_WITH_PLUGINS AND NOT LWS_WITH_LIBUV)
message(STATUS "LWS_WITH_PLUGINS --> Enabling LWS_WITH_LIBUV")
set(LWS_WITH_LIBUV 1)
endif()
if (LWS_WITH_SMTP AND NOT LWS_WITH_LIBUV)
message(STATUS "LWS_WITH_SMTP --> Enabling LWS_WITH_LIBUV")
set(LWS_WITH_LIBUV 1)
endif()
if (LWS_WITH_PLUGINS OR LWS_WITH_CGI)
# sshd plugin
set(LWS_WITH_GENHASH 1)
set(LWS_WITH_GENRSA 1)
endif()
if (LWS_WITH_GENERIC_SESSIONS)
set(LWS_WITH_SQLITE3 1)
set(LWS_WITH_SMTP 1)
endif()
if (LWS_WITH_SMTP AND NOT LWS_WITH_LIBUV)
message(STATUS "LWS_WITH_SMTP --> Enabling LWS_WITH_LIBUV")
set(LWS_WITH_LIBUV 1)
endif()
if (LWS_WITH_ESP32)
set(LWS_WITH_SHARED OFF)
set(LWS_WITH_MBEDTLS ON)
# set(LWS_WITHOUT_CLIENT ON)
set(LWS_WITHOUT_TESTAPPS ON)
set(LWS_WITHOUT_EXTENSIONS ON)
set(LWS_WITH_PLUGINS OFF)
set(LWS_WITH_RANGES ON)
# this implies no pthreads in the lib
set(LWS_MAX_SMP 1)
set(LWS_HAVE_MALLOC 1)
set(LWS_HAVE_REALLOC 1)
set(LWS_HAVE_GETIFADDRS 1)
set(LWS_WITH_ZIP_FOPS 1)
endif()
if (WIN32)
# this implies no pthreads in the lib
set(LWS_MAX_SMP 1)
endif()
if (LWS_WITHOUT_SERVER)
set(LWS_WITH_LWSWS OFF)
endif()
if (LWS_WITH_HTTP_PROXY AND (LWS_WITHOUT_CLIENT OR LWS_WITHOUT_SERVER))
message(FATAL_ERROR "You have to enable both client and server for http proxy")
endif()
# Allow the user to override installation directories.
set(LWS_INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
set(LWS_INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
set(LWS_INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
set(LWS_INSTALL_EXAMPLES_DIR bin CACHE PATH "Installation directory for example files")
# Allow the user to use the old CyaSSL options/library in stead of wolfSSL
if (LWS_WITH_CYASSL AND LWS_WITH_WOLFSSL)
message(FATAL_ERROR "LWS_WITH_CYASSL and LWS_WITH_WOLFSSL are mutually exclusive!")
endif()
if (LWS_WITH_CYASSL)
# Copy CyaSSL options to the wolfSSL options
set(LWS_WITH_WOLFSSL ${LWS_WITH_CYASSL} CACHE BOOL "Use wolfSSL/CyaSSL instead of OpenSSL" FORCE)
set(LWS_WOLFSSL_LIBRARIES ${LWS_CYASSL_LIBRARIES} CACHE PATH "Path to wolfSSL/CyaSSL libraries" FORCE)
set(LWS_WOLFSSL_INCLUDE_DIRS ${LWS_CYASSL_INCLUDE_DIRS} CACHE PATH "Path to wolfSSL/CyaSSL header files" FORCE)
endif()
if (LWS_WITHOUT_CLIENT AND LWS_WITHOUT_SERVER)
message(FATAL_ERROR "Makes no sense to compile with neither client nor server.")
endif()
if (NOT (LWS_WITH_STATIC OR LWS_WITH_SHARED))
message(FATAL_ERROR "Makes no sense to compile with neither static nor shared libraries.")
endif()
if (NOT LWS_WITHOUT_EXTENSIONS OR LWS_WITH_ZIP_FOPS)
set(LWS_WITH_ZLIB 1)
endif()
set(LWS_ZLIB_LIBRARIES CACHE PATH "Path to the zlib library")
set(LWS_ZLIB_INCLUDE_DIRS CACHE PATH "Path to the zlib include directory")
set(LWS_OPENSSL_LIBRARIES CACHE PATH "Path to the OpenSSL library")
set(LWS_OPENSSL_INCLUDE_DIRS CACHE PATH "Path to the OpenSSL include directory")
set(LWS_WOLFSSL_LIBRARIES CACHE PATH "Path to the wolfSSL library")
set(LWS_WOLFSSL_INCLUDE_DIRS CACHE PATH "Path to the wolfSSL include directory")
set(LWS_LIBEV_LIBRARIES CACHE PATH "Path to the libev library")
set(LWS_LIBEV_INCLUDE_DIRS CACHE PATH "Path to the libev include directory")
set(LWS_LIBUV_LIBRARIES CACHE PATH "Path to the libuv library")
set(LWS_LIBUV_INCLUDE_DIRS CACHE PATH "Path to the libuv include directory")
set(LWS_SQLITE3_LIBRARIES CACHE PATH "Path to the sqlite3 library")
set(LWS_SQLITE3_INCLUDE_DIRS CACHE PATH "Path to the sqlite3 include directory")
set(LWS_LIBEVENT_INCLUDE_DIRS CACHE PATH "Path to the libevent include directory")
set(LWS_LIBEVENT_LIBRARIES CACHE PATH "Path to the libevent library")
if (NOT LWS_WITH_SSL)
set(LWS_WITHOUT_BUILTIN_SHA1 OFF)
endif()
if (LWS_WITH_SSL AND NOT LWS_WITH_WOLFSSL AND NOT LWS_WITH_MBEDTLS)
if ("${LWS_OPENSSL_LIBRARIES}" STREQUAL "" OR "${LWS_OPENSSL_INCLUDE_DIRS}" STREQUAL "")
else()
if (NOT LWS_WITH_ESP32)
set(OPENSSL_LIBRARIES ${LWS_OPENSSL_LIBRARIES})
endif()
set(OPENSSL_INCLUDE_DIRS ${LWS_OPENSSL_INCLUDE_DIRS})
set(OPENSSL_FOUND 1)
endif()
endif()
if (LWS_WITH_SSL AND LWS_WITH_WOLFSSL)
if ("${LWS_WOLFSSL_LIBRARIES}" STREQUAL "" OR "${LWS_WOLFSSL_INCLUDE_DIRS}" STREQUAL "")
if (NOT WOLFSSL_FOUND)
if (LWS_WITH_CYASSL)
message(FATAL_ERROR "You must set LWS_CYASSL_LIBRARIES and LWS_CYASSL_INCLUDE_DIRS when LWS_WITH_CYASSL is turned on.")
else()
message(FATAL_ERROR "You must set LWS_WOLFSSL_LIBRARIES and LWS_WOLFSSL_INCLUDE_DIRS when LWS_WITH_WOLFSSL is turned on.")
endif()
endif()
else()
set(WOLFSSL_LIBRARIES ${LWS_WOLFSSL_LIBRARIES})
set(WOLFSSL_INCLUDE_DIRS ${LWS_WOLFSSL_INCLUDE_DIRS})
set(WOLFSSL_FOUND 1)
endif()
set(USE_WOLFSSL 1)
if (LWS_WITH_CYASSL)
set(USE_OLD_CYASSL 1)
endif()
endif()
if (LWS_WITH_SSL AND LWS_WITH_MBEDTLS)
if ("${LWS_MBEDTLS_LIBRARIES}" STREQUAL "" OR "${LWS_MBEDTLS_INCLUDE_DIRS}" STREQUAL "" AND NOT LWS_WITH_ESP32)
find_path(LWS_MBEDTLS_INCLUDE_DIRS mbedtls/ssl.h)
find_library(MBEDTLS_LIBRARY mbedtls)
find_library(MBEDX509_LIBRARY mbedx509)
find_library(MBEDCRYPTO_LIBRARY mbedcrypto)
set(LWS_MBEDTLS_LIBRARIES "${MBEDTLS_LIBRARY}" "${MBEDX509_LIBRARY}" "${MBEDCRYPTO_LIBRARY}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MBEDTLS DEFAULT_MSG
LWS_MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)
mark_as_advanced(LWS_MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)
if ("${LWS_MBEDTLS_LIBRARIES}" STREQUAL "" OR "${LWS_MBEDTLS_INCLUDE_DIRS}" STREQUAL "")
message(FATAL_ERROR "You must set LWS_MBEDTLS_LIBRARIES and LWS_MBEDTLS_INCLUDE_DIRS when LWS_WITH_MBEDTLS is turned on.")
endif()
endif()
set(MBEDTLS_LIBRARIES ${LWS_MBEDTLS_LIBRARIES})
set(MBEDTLS_INCLUDE_DIRS ${LWS_MBEDTLS_INCLUDE_DIRS})
set(MBEDTLS_FOUND 1)
set(USE_MBEDTLS 1)
endif()
if (LWS_WITH_ZLIB AND NOT LWS_WITH_BUNDLED_ZLIB)
if ("${LWS_ZLIB_LIBRARIES}" STREQUAL "" OR "${LWS_ZLIB_INCLUDE_DIRS}" STREQUAL "")
else()
set(ZLIB_LIBRARIES ${LWS_ZLIB_LIBRARIES})
set(ZLIB_INCLUDE_DIRS ${LWS_ZLIB_INCLUDE_DIRS})
set(ZLIB_FOUND 1)
endif()
endif()
if (LWS_WITH_LIBEV)
if ("${LWS_LIBEV_LIBRARIES}" STREQUAL "" OR "${LWS_LIBEV_INCLUDE_DIRS}" STREQUAL "")
else()
set(LIBEV_LIBRARIES ${LWS_LIBEV_LIBRARIES})
set(LIBEV_INCLUDE_DIRS ${LWS_LIBEV_INCLUDE_DIRS})
set(LIBEV_FOUND 1)
endif()
endif()
if (LWS_WITH_LIBUV)
if ("${LWS_LIBUV_LIBRARIES}" STREQUAL "" OR "${LWS_LIBUV_INCLUDE_DIRS}" STREQUAL "")
else()
set(LIBUV_LIBRARIES ${LWS_LIBUV_LIBRARIES})
set(LIBUV_INCLUDE_DIRS ${LWS_LIBUV_INCLUDE_DIRS})
set(LIBUV_FOUND 1)
endif()
endif()
if (LWS_WITH_LIBEVENT)
if ("${LWS_LIBEVENT_LIBRARIES}" STREQUAL "" OR "${LWS_LIBEVENT_INCLUDE_DIRS}" STREQUAL "")
else()
set(LIBEVENT_LIBRARIES ${LWS_LIBEVENT_LIBRARIES})
set(LIBEVENT_INCLUDE_DIRS ${LWS_LIBEVENT_INCLUDE_DIRS})
set(LIBEVENT_FOUND 1)
endif()
endif()
if (LWS_WITH_SQLITE3)
if ("${LWS_SQLITE3_LIBRARIES}" STREQUAL "" OR "${LWS_SQLITE3_INCLUDE_DIRS}" STREQUAL "")
else()
set(SQLITE3_LIBRARIES ${LWS_SQLITE3_LIBRARIES})
set(SQLITE3_INCLUDE_DIRS ${LWS_SQLITE3_INCLUDE_DIRS})
set(SQLITE3_FOUND 1)
endif()
endif()
# The base dir where the test-apps look for the SSL certs.
set(LWS_OPENSSL_CLIENT_CERTS ../share CACHE PATH "Server SSL certificate directory")
if (WIN32)
set(LWS_OPENSSL_CLIENT_CERTS . CACHE PATH "Client SSL certificate directory")
if (LWS_UNIX_SOCK)
set(LWS_UNIX_SOCK OFF)
message(WARNING "Windows does not support UNIX domain sockets")
endif()
else()
set(LWS_OPENSSL_CLIENT_CERTS /etc/pki/tls/certs/ CACHE PATH "Client SSL certificate directory")
endif()
if (LWS_WITHOUT_EXTENSIONS)
set(LWS_NO_EXTENSIONS 1)
endif()
if (LWS_WITH_SSL)
set(LWS_OPENSSL_SUPPORT 1)
endif()
if (LWS_SSL_CLIENT_USE_OS_CA_CERTS)
set(LWS_SSL_CLIENT_USE_OS_CA_CERTS 1)
endif()
if (LWS_WITH_LATENCY)
set(LWS_LATENCY 1)
endif()
if (LWS_WITHOUT_DAEMONIZE OR WIN32)
set(LWS_NO_DAEMONIZE 1)
endif()
if (LWS_WITHOUT_SERVER)
set(LWS_NO_SERVER 1)
endif()
if (LWS_WITHOUT_CLIENT)
set(LWS_NO_CLIENT 1)
endif()
if (LWS_WITH_LIBEV)
set(LWS_WITH_LIBEV 1)
endif()
if (LWS_WITH_LIBUV)
set(LWS_WITH_LIBUV 1)
endif()
if (LWS_WITH_LIBEVENT)
set(LWS_WITH_LIBEVENT 1)
endif()
if (LWS_IPV6)
set(LWS_WITH_IPV6 1)
endif()
if (LWS_UNIX_SOCK)
set(LWS_WITH_UNIX_SOCK 1)
endif()
if (LWS_WITH_HTTP2)
set(LWS_WITH_HTTP2 1)
endif()
if ("${LWS_MAX_SMP}" STREQUAL "")
set(LWS_MAX_SMP 1)
endif()
if (MINGW)
set(LWS_MINGW_SUPPORT 1)
set(CMAKE_C_FLAGS "-D__USE_MINGW_ANSI_STDIO ${CMAKE_C_FLAGS}")
add_definitions(-DWINVER=0x0601 -D_WIN32_WINNT=0x0601)
endif()
if (LWS_SSL_SERVER_WITH_ECDH_CERT)
set(LWS_SSL_SERVER_WITH_ECDH_CERT 1)
endif()
include_directories("${PROJECT_BINARY_DIR}")
include(CheckCSourceCompiles)
# Check for different inline keyword versions.
foreach(KEYWORD "inline" "__inline__" "__inline")
set(CMAKE_REQUIRED_DEFINITIONS "-DKEYWORD=${KEYWORD}")
CHECK_C_SOURCE_COMPILES(
"
#include <stdio.h>
static KEYWORD void a() {}
int main(int argc, char **argv) { a(); return 0; }
" LWS_HAVE_${KEYWORD})
endforeach()
if (NOT LWS_HAVE_inline)
if (LWS_HAVE___inline__)
set(inline __inline__)
elseif(LWS_HAVE___inline)
set(inline __inline)
endif()
endif()
# Put the libraries and binaries that get built into directories at the
# top of the build tree rather than in hard-to-find leaf directories.
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
SET(LWS_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}")
# Put absolute path of dynamic libraries into the object code. Some
# architectures, notably Mac OS X, need this.
SET(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${LWS_INSTALL_LIB_DIR}${LIB_SUFFIX}")
include(CheckFunctionExists)
include(CheckSymbolExists)
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckLibraryExists)
include(CheckTypeSize)
if (LWS_WITHOUT_BUILTIN_SHA1)
set(LWS_SHA1_USE_OPENSSL_NAME 1)
endif()
if (HAIKU)
set(CMAKE_REQUIRED_LIBRARIES network)
endif()
CHECK_FUNCTION_EXISTS(bzero LWS_HAVE_BZERO)
CHECK_FUNCTION_EXISTS(fork LWS_HAVE_FORK)
CHECK_FUNCTION_EXISTS(getenv LWS_HAVE_GETENV)
CHECK_FUNCTION_EXISTS(malloc LWS_HAVE_MALLOC)
CHECK_FUNCTION_EXISTS(memset LWS_HAVE_MEMSET)
CHECK_FUNCTION_EXISTS(realloc LWS_HAVE_REALLOC)
CHECK_FUNCTION_EXISTS(socket LWS_HAVE_SOCKET)
CHECK_FUNCTION_EXISTS(strerror LWS_HAVE_STRERROR)
CHECK_FUNCTION_EXISTS(vfork LWS_HAVE_VFORK)
CHECK_FUNCTION_EXISTS(execvpe LWS_HAVE_EXECVPE)
CHECK_FUNCTION_EXISTS(getifaddrs LWS_HAVE_GETIFADDRS)
CHECK_FUNCTION_EXISTS(snprintf LWS_HAVE_SNPRINTF)
CHECK_FUNCTION_EXISTS(_snprintf LWS_HAVE__SNPRINTF)
CHECK_FUNCTION_EXISTS(_vsnprintf LWS_HAVE__VSNPRINTF)
CHECK_FUNCTION_EXISTS(getloadavg LWS_HAVE_GETLOADAVG)
CHECK_FUNCTION_EXISTS(atoll LWS_HAVE_ATOLL)
CHECK_FUNCTION_EXISTS(_atoi64 LWS_HAVE__ATOI64)
CHECK_FUNCTION_EXISTS(_stat32i64 LWS_HAVE__STAT32I64)
if (NOT LWS_HAVE_GETIFADDRS)
if (LWS_WITHOUT_BUILTIN_GETIFADDRS)
message(FATAL_ERROR "No getifaddrs was found on the system. Turn off the LWS_WITHOUT_BUILTIN_GETIFADDRS compile option to use the supplied BSD version.")
endif()
set(LWS_BUILTIN_GETIFADDRS 1)
endif()
CHECK_INCLUDE_FILE(dlfcn.h LWS_HAVE_DLFCN_H)
CHECK_INCLUDE_FILE(fcntl.h LWS_HAVE_FCNTL_H)
CHECK_INCLUDE_FILE(in6addr.h LWS_HAVE_IN6ADDR_H)
CHECK_INCLUDE_FILE(inttypes.h LWS_HAVE_INTTYPES_H)
CHECK_INCLUDE_FILE(memory.h LWS_HAVE_MEMORY_H)
CHECK_INCLUDE_FILE(netinet/in.h LWS_HAVE_NETINET_IN_H)
CHECK_INCLUDE_FILE(stdint.h LWS_HAVE_STDINT_H)
CHECK_INCLUDE_FILE(stdlib.h LWS_HAVE_STDLIB_H)
CHECK_INCLUDE_FILE(strings.h LWS_HAVE_STRINGS_H)
CHECK_INCLUDE_FILE(string.h LWS_HAVE_STRING_H)
CHECK_INCLUDE_FILE(sys/prctl.h LWS_HAVE_SYS_PRCTL_H)
CHECK_INCLUDE_FILE(sys/socket.h LWS_HAVE_SYS_SOCKET_H)
CHECK_INCLUDE_FILE(sys/sockio.h LWS_HAVE_SYS_SOCKIO_H)
CHECK_INCLUDE_FILE(sys/stat.h LWS_HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILE(sys/types.h LWS_HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILE(unistd.h LWS_HAVE_UNISTD_H)
CHECK_INCLUDE_FILE(vfork.h LWS_HAVE_VFORK_H)
CHECK_INCLUDE_FILE(sys/capability.h LWS_HAVE_SYS_CAPABILITY_H)
CHECK_INCLUDE_FILE(malloc.h LWS_HAVE_MALLOC_H)
CHECK_LIBRARY_EXISTS(cap cap_set_flag "" LWS_HAVE_LIBCAP)
if (LWS_WITH_LIBUV)
CHECK_INCLUDE_FILE(uv-version.h LWS_HAVE_UV_VERSION_H)
endif()
if (LWS_WITH_ZLIB AND NOT LWS_WITH_BUNDLED_ZLIB)
CHECK_INCLUDE_FILE(zlib.h LWS_HAVE_ZLIB_H)
endif()
# TODO: These can also be tested to see whether they actually work...
set(LWS_HAVE_WORKING_FORK LWS_HAVE_FORK)
set(LWS_HAVE_WORKING_VFORK LWS_HAVE_VFORK)
CHECK_INCLUDE_FILES("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
CHECK_C_SOURCE_COMPILES("#include <stdint.h>
int main(void) {
intptr_t test = 1;
return 0;
}" LWS_HAS_INTPTR_T)
# These don't work Cross...
#CHECK_TYPE_SIZE(pid_t PID_T_SIZE)
#CHECK_TYPE_SIZE(size_t SIZE_T_SIZE)
#CHECK_TYPE_SIZE("void *" LWS_SIZEOFPTR LANGUAGE C)
if (NOT PID_T_SIZE)
set(pid_t int)
endif()
if (NOT SIZE_T_SIZE)
set(size_t "unsigned int")
endif()
if (NOT LWS_HAVE_MALLOC)
set(malloc rpl_malloc)
endif()
if (NOT LWS_HAVE_REALLOC)
set(realloc rpl_realloc)
endif()
if (MSVC)
# Turn off stupid microsoft security warnings.
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
endif(MSVC)
include_directories("${PROJECT_SOURCE_DIR}/lib")
# Group headers and sources.
# Some IDEs use this for nicer file structure.
set(HDR_PRIVATE
lib/private-libwebsockets.h)
set(HDR_PUBLIC
"${PROJECT_SOURCE_DIR}/lib/libwebsockets.h"
"${PROJECT_BINARY_DIR}/lws_config.h"
"${PROJECT_SOURCE_DIR}/plugins/ssh-base/include/lws-plugin-ssh.h"
)
set(SOURCES
lib/misc/base64-decode.c
lib/handshake.c
lib/libwebsockets.c
lib/service.c
lib/pollfd.c
lib/output.c
lib/server/parsers.c
lib/context.c
lib/alloc.c
lib/header.c
lib/misc/lws-ring.c)
if (LWS_WITH_CGI)
list(APPEND SOURCES
lib/server/cgi.c)
endif()
if (LWS_WITH_ACCESS_LOG)
list(APPEND SOURCES
lib/server/access-log.c)
endif()
if (LWS_WITH_PEER_LIMITS)
list(APPEND SOURCES
lib/server/peer-limits.c)
endif()
if (NOT LWS_WITHOUT_CLIENT)
list(APPEND SOURCES
lib/client/client.c
lib/client/client-handshake.c
lib/client/client-parser.c)
endif()
if (LWS_WITH_MBEDTLS)
set(LWS_WITH_SSL ON)
list(APPEND HDR_PRIVATE
lib/tls/mbedtls/wrapper/include/internal/ssl3.h
lib/tls/mbedtls/wrapper/include/internal/ssl_cert.h
lib/tls/mbedtls/wrapper/include/internal/ssl_code.h
lib/tls/mbedtls/wrapper/include/internal/ssl_dbg.h
lib/tls/mbedtls/wrapper/include/internal/ssl_lib.h
lib/tls/mbedtls/wrapper/include/internal/ssl_methods.h
lib/tls/mbedtls/wrapper/include/internal/ssl_pkey.h
lib/tls/mbedtls/wrapper/include/internal/ssl_stack.h
lib/tls/mbedtls/wrapper/include/internal/ssl_types.h
lib/tls/mbedtls/wrapper/include/internal/ssl_x509.h
lib/tls/mbedtls/wrapper/include/internal/tls1.h
lib/tls/mbedtls/wrapper/include/internal/x509_vfy.h)
list(APPEND HDR_PRIVATE
lib/tls/mbedtls/wrapper/include/openssl/ssl.h)
list(APPEND HDR_PRIVATE
lib/tls/mbedtls/wrapper/include/platform/ssl_pm.h
lib/tls/mbedtls/wrapper/include/platform/ssl_port.h)
include_directories(lib/tls/mbedtls/wrapper/include)
include_directories(lib/tls/mbedtls/wrapper/include/platform)
include_directories(lib/tls/mbedtls/wrapper/include/internal)
include_directories(lib/tls/mbedtls/wrapper/include/openssl)
list(APPEND SOURCES
lib/tls/mbedtls/wrapper/library/ssl_cert.c
lib/tls/mbedtls/wrapper/library/ssl_lib.c
lib/tls/mbedtls/wrapper/library/ssl_methods.c
lib/tls/mbedtls/wrapper/library/ssl_pkey.c
lib/tls/mbedtls/wrapper/library/ssl_stack.c
lib/tls/mbedtls/wrapper/library/ssl_x509.c)
list(APPEND SOURCES
lib/tls/mbedtls/wrapper/platform/ssl_pm.c
lib/tls/mbedtls/wrapper/platform/ssl_port.c)
endif()
if (LWS_WITH_SSL)
list(APPEND SOURCES
lib/tls/tls.c
)
if (LWS_WITH_MBEDTLS)
list(APPEND SOURCES
lib/tls/mbedtls/ssl.c
)
if (LWS_WITH_GENHASH)
list(APPEND SOURCES
lib/tls/mbedtls/lws-genhash.c
)
endif()
if (LWS_WITH_GENRSA)
list(APPEND SOURCES
lib/tls/mbedtls/lws-genrsa.c
)
endif()
else()
list(APPEND SOURCES
lib/tls/openssl/ssl.c
)
if (LWS_WITH_GENHASH)
list(APPEND SOURCES
lib/tls/openssl/lws-genhash.c
)
endif()
if (LWS_WITH_GENRSA)
list(APPEND SOURCES
lib/tls/openssl/lws-genrsa.c
)
endif()
endif()
if (NOT LWS_WITHOUT_SERVER)
list(APPEND SOURCES
lib/server/ssl-server.c)
if (LWS_WITH_MBEDTLS)
list(APPEND SOURCES
lib/tls/mbedtls/mbedtls-server.c)
else()
list(APPEND SOURCES
lib/tls/openssl/openssl-server.c)
endif()
endif()
if (NOT LWS_WITHOUT_CLIENT)
list(APPEND SOURCES
lib/client/ssl-client.c)
if (LWS_WITH_MBEDTLS)
list(APPEND SOURCES
lib/tls/mbedtls/mbedtls-client.c)
else()
list(APPEND SOURCES
lib/tls/openssl/openssl-client.c)
endif()
endif()
endif()
if (NOT LWS_WITHOUT_BUILTIN_SHA1)
list(APPEND SOURCES
lib/misc/sha-1.c)
endif()
if (LWS_WITH_HTTP2)
list(APPEND SOURCES
lib/http2/http2.c
lib/http2/hpack.c
lib/http2/ssl-http2.c)
endif()
# select the active platform files
if (WIN32)
list(APPEND SOURCES
lib/plat/lws-plat-win.c)
else()
if (LWS_PLAT_OPTEE)
list(APPEND SOURCES
lib/plat/lws-plat-optee.c)
else()
if (LWS_WITH_ESP32)
list(APPEND SOURCES
lib/plat/lws-plat-esp32.c
lib/misc/romfs.c)
else()
list(APPEND SOURCES
lib/plat/lws-plat-unix.c)
endif()
endif()
endif()
if (NOT LWS_WITHOUT_SERVER)
list(APPEND SOURCES
lib/server/server.c
lib/server/lws-spa.c
lib/server/server-handshake.c)
endif()
if (NOT LWS_WITHOUT_EXTENSIONS)
list(APPEND HDR_PRIVATE
lib/ext/extension-permessage-deflate.h)
list(APPEND SOURCES
lib/ext/extension.c
lib/ext/extension-permessage-deflate.c)
endif()
if (LWS_WITH_HTTP_PROXY)
list(APPEND SOURCES
lib/server/rewrite.c)
endif()
if (LWS_WITH_LIBEV)
list(APPEND SOURCES
lib/event-libs/libev.c)
endif()
if (LWS_WITH_LIBUV)
list(APPEND SOURCES
lib/event-libs/libuv.c)
endif()
if (LWS_WITH_LIBEVENT)
list(APPEND SOURCES
lib/event-libs/libevent.c)
endif()
if (LWS_WITH_LEJP)
list(APPEND SOURCES
lib/misc/lejp.c)
endif()
if (LWS_WITH_LEJP_CONF)
list(APPEND SOURCES
"lib/server/lejp-conf.c"
)
endif()
if (LWS_WITH_SMTP)
list(APPEND SOURCES
lib/misc/smtp.c)
endif()
if (LWS_WITH_RANGES)
list(APPEND SOURCES
lib/server/ranges.c)
endif()
if (LWS_WITH_ZIP_FOPS)
if (LWS_WITH_ZLIB)
list(APPEND SOURCES
lib/server/fops-zip.c)
else()
message(FATAL_ERROR "Pre-zipped file support (LWS_WITH_ZIP_FOPS) requires ZLIB (LWS_WITH_ZLIB)")
endif()
endif()
if (LWS_WITH_JWS)
list(APPEND SOURCES
lib/jws/jwk.c
lib/jws/jws.c)
endif()
# Add helper files for Windows.
if (WIN32)
set(WIN32_HELPERS_PATH win32port/win32helpers)
include_directories(${WIN32_HELPERS_PATH})
if (WIN32)
list(APPEND SOURCES
${WIN32_HELPERS_PATH}/gettimeofday.c
)
list(APPEND HDR_PRIVATE
${WIN32_HELPERS_PATH}/gettimeofday.h
)
endif(WIN32)
else()
# Unix.
if (NOT LWS_WITHOUT_DAEMONIZE)
list(APPEND SOURCES
lib/server/daemonize.c)
endif()
endif()
if (UNIX)
if (NOT LWS_HAVE_GETIFADDRS)
list(APPEND HDR_PRIVATE lib/misc/getifaddrs.h)
list(APPEND SOURCES lib/misc/getifaddrs.c)
endif()
endif()
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
include (CheckCCompilerFlag)
CHECK_C_COMPILER_FLAG(-fvisibility=hidden LWS_HAVE_VISIBILITY)
if (LWS_HAVE_VISIBILITY)
set(VISIBILITY_FLAG -fvisibility=hidden)
endif()
if (LWS_WITH_GCOV)
set (GCOV_FLAGS "-fprofile-arcs -ftest-coverage -O0")
endif()
if (UNIX AND NOT LWS_WITH_ESP32)
set(CMAKE_C_FLAGS "-Wall -Wsign-compare -Wignored-qualifiers -Wtype-limits -Wuninitialized -Werror ${VISIBILITY_FLAG} -Wundef ${GCOV_FLAGS} ${CMAKE_C_FLAGS}" )
else()
set(CMAKE_C_FLAGS "-Wall -Wsign-compare -Wignored-qualifiers -Wtype-limits -Wuninitialized -Werror ${VISIBILITY_FLAG} ${GCOV_FLAGS} ${CMAKE_C_FLAGS}" )
endif()
endif ()
if ((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) AND NOT LWS_WITHOUT_TESTAPPS)
if (UNIX AND LWS_MAX_SMP GREATER 1)
# jeez clang understands -pthread but dies if he sees it at link time!
# http://stackoverflow.com/questions/2391194/what-is-gs-pthread-equiv-in-clang
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread" )
endif()
endif()
if ((CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
# otherwise osx blows a bunch of openssl deprecated api errors
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations" )
endif()
source_group("Headers Private" FILES ${HDR_PRIVATE})
source_group("Headers Public" FILES ${HDR_PUBLIC})
source_group("Sources" FILES ${SOURCES})
source_group("Resources" FILES ${RESOURCES})
#
# Create the lib.
#
set(LWS_LIBRARIES)
if (LWS_WITH_STATIC)
if (LWS_STATIC_PIC)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
add_library(websockets STATIC
${HDR_PRIVATE}
${HDR_PUBLIC}
${SOURCES})
list(APPEND LWS_LIBRARIES websockets)
if (WIN32)
# Windows uses the same .lib ending for static libraries and shared
# library linker files, so rename the static library.
set_target_properties(websockets
PROPERTIES
OUTPUT_NAME websockets_static)
endif()
add_custom_command(
TARGET websockets
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/lib/libwebsockets.h
${CMAKE_CURRENT_BINARY_DIR}/include/libwebsockets.h
)