-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
221 lines (192 loc) · 7.43 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
cmake_minimum_required(VERSION 3.0)
project(websocket VERSION 1.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-implicit-function-declaration")
set(CMAKE_CONFIGURATION_TYPES "debug;release" CACHE STRING "Configurations" FORCE)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/mbedtls/include
${CMAKE_CURRENT_SOURCE_DIR}/websocket/include
)
set(MBEDTLS
websocket/library/mbedtls/aes.c
websocket/library/mbedtls/aesni.c
websocket/library/mbedtls/aria.c
websocket/library/mbedtls/asn1parse.c
websocket/library/mbedtls/asn1write.c
websocket/library/mbedtls/base64.c
websocket/library/mbedtls/bignum.c
websocket/library/mbedtls/camellia.c
websocket/library/mbedtls/ccm.c
websocket/library/mbedtls/chacha20.c
websocket/library/mbedtls/chachapoly.c
websocket/library/mbedtls/cipher.c
websocket/library/mbedtls/cipher_wrap.c
websocket/library/mbedtls/cmac.c
websocket/library/mbedtls/constant_time.c
websocket/library/mbedtls/ctr_drbg.c
websocket/library/mbedtls/debug.c
websocket/library/mbedtls/des.c
websocket/library/mbedtls/dhm.c
websocket/library/mbedtls/ecdh.c
websocket/library/mbedtls/ecdsa.c
websocket/library/mbedtls/ecjpake.c
websocket/library/mbedtls/ecp.c
websocket/library/mbedtls/ecp_curves.c
websocket/library/mbedtls/entropy.c
websocket/library/mbedtls/entropy_poll.c
websocket/library/mbedtls/error.c
websocket/library/mbedtls/gcm.c
websocket/library/mbedtls/hkdf.c
websocket/library/mbedtls/hmac_drbg.c
websocket/library/mbedtls/md.c
websocket/library/mbedtls/md5.c
websocket/library/mbedtls/memory_buffer_alloc.c
websocket/library/mbedtls/mps_reader.c
websocket/library/mbedtls/mps_trace.c
websocket/library/mbedtls/net_sockets.c
websocket/library/mbedtls/nist_kw.c
websocket/library/mbedtls/oid.c
websocket/library/mbedtls/padlock.c
websocket/library/mbedtls/pem.c
websocket/library/mbedtls/pk.c
websocket/library/mbedtls/pkcs12.c
websocket/library/mbedtls/pkcs5.c
websocket/library/mbedtls/pkparse.c
websocket/library/mbedtls/pkwrite.c
websocket/library/mbedtls/pk_wrap.c
websocket/library/mbedtls/platform.c
websocket/library/mbedtls/platform_util.c
websocket/library/mbedtls/poly1305.c
websocket/library/mbedtls/psa_crypto.c
websocket/library/mbedtls/psa_crypto_aead.c
websocket/library/mbedtls/psa_crypto_cipher.c
websocket/library/mbedtls/psa_crypto_client.c
websocket/library/mbedtls/psa_crypto_driver_wrappers.c
websocket/library/mbedtls/psa_crypto_ecp.c
websocket/library/mbedtls/psa_crypto_hash.c
websocket/library/mbedtls/psa_crypto_mac.c
websocket/library/mbedtls/psa_crypto_rsa.c
websocket/library/mbedtls/psa_crypto_se.c
websocket/library/mbedtls/psa_crypto_slot_management.c
websocket/library/mbedtls/psa_crypto_storage.c
websocket/library/mbedtls/psa_its_file.c
websocket/library/mbedtls/ripemd160.c
websocket/library/mbedtls/rsa.c
websocket/library/mbedtls/rsa_alt_helpers.c
websocket/library/mbedtls/sha1.c
websocket/library/mbedtls/sha256.c
websocket/library/mbedtls/sha512.c
websocket/library/mbedtls/ssl_cache.c
websocket/library/mbedtls/ssl_ciphersuites.c
websocket/library/mbedtls/ssl_cli.c
websocket/library/mbedtls/ssl_cookie.c
websocket/library/mbedtls/ssl_debug_helpers_generated.c
websocket/library/mbedtls/ssl_msg.c
websocket/library/mbedtls/ssl_srv.c
websocket/library/mbedtls/ssl_ticket.c
websocket/library/mbedtls/ssl_tls.c
websocket/library/mbedtls/ssl_tls13_client.c
websocket/library/mbedtls/ssl_tls13_generic.c
websocket/library/mbedtls/ssl_tls13_keys.c
websocket/library/mbedtls/ssl_tls13_server.c
websocket/library/mbedtls/threading.c
websocket/library/mbedtls/timing.c
websocket/library/mbedtls/version.c
websocket/library/mbedtls/version_features.c
websocket/library/mbedtls/x509.c
websocket/library/mbedtls/x509write_crt.c
websocket/library/mbedtls/x509write_csr.c
websocket/library/mbedtls/x509_create.c
websocket/library/mbedtls/x509_crl.c
websocket/library/mbedtls/x509_crt.c
websocket/library/mbedtls/x509_csr.c
)
set(API
websocket/library/websocket/websocket_c_api.cpp
)
set(ZLIB
websocket/library/websocket/gzclose.c
websocket/library/websocket/gzlib.c
websocket/library/websocket/gzread.c
websocket/library/websocket/gzwrite.c
websocket/library/websocket/adler32.c
websocket/library/websocket/crc32.c
websocket/library/websocket/trees.c
websocket/library/websocket/inftrees.c
websocket/library/websocket/inffast.c
websocket/library/websocket/zutil.c
websocket/library/websocket/deflate.c
websocket/library/websocket/inflate.c
)
set(CORE
websocket/library/websocket/flate.cpp
websocket/library/websocket/byte_stream.cpp
websocket/library/websocket/endian.cpp
websocket/library/websocket/http.cpp
websocket/library/websocket/handshake.cpp
websocket/library/websocket/frame.cpp
websocket/library/websocket/websocket.cpp
)
set(SOURCES
websocket/library/websocket/example.cpp
)
source_group("mbedtls" FILES ${MBEDTLS})
source_group("zlib" FILES ${ZLIB})
source_group("websocket" FILES ${CORE} ${API} ${SOURCES})
option(ENABLE_C_API "enable c api" ON)
option(ENABLE_CPP_API "enable cpp api" ON)
option(BUILD_SHARED "build shared library" OFF)
option(BUILD_STATIC "build static library" OFF)
option(BUILD_EXAMPLE "build example" ON)
option(EXAMPLE_C_API "use c api in example build" OFF)
if(BUILD_SHARED)
add_library(LIB_SHARED SHARED ${MBEDTLS} ${API} ${ZLIB} ${CORE})
target_compile_definitions(LIB_SHARED PRIVATE WEBSOCKET_SHARED WEBSOCKET_EXPORT)
if(ENABLE_CPP_API)
target_compile_definitions(LIB_SHARED PRIVATE WEBSOCKET_CPP_API)
endif()
if(ENABLE_C_API)
target_compile_definitions(LIB_SHARED PRIVATE WEBSOCKET_C_API)
endif()
if(WIN32)
target_link_libraries(LIB_SHARED wsock32 ws2_32)
endif()
endif()
if(BUILD_STATIC)
add_library(LIB_STATIC STATIC ${MBEDTLS} ${API} ${ZLIB} ${CORE})
if(ENABLE_CPP_API)
target_compile_definitions(LIB_STATIC PRIVATE WEBSOCKET_CPP_API)
endif()
if(ENABLE_C_API)
target_compile_definitions(LIB_STATIC PRIVATE WEBSOCKET_C_API)
endif()
if(WIN32)
target_link_libraries(LIB_STATIC wsock32 ws2_32)
endif()
endif()
if(BUILD_EXAMPLE)
add_executable(EXAMPLE_CLIENT ${MBEDTLS} ${API} ${ZLIB} ${CORE} ${SOURCES})
target_compile_definitions(EXAMPLE_CLIENT PRIVATE WEBSOCKET_EXAMPLE_ENDPOINT_CLIENT)
add_executable(EXAMPLE_SERVER ${MBEDTLS} ${API} ${ZLIB} ${CORE} ${SOURCES})
target_compile_definitions(EXAMPLE_SERVER PRIVATE WEBSOCKET_EXAMPLE_ENDPOINT_SERVER)
if(ENABLE_CPP_API)
target_compile_definitions(EXAMPLE_CLIENT PRIVATE WEBSOCKET_CPP_API)
target_compile_definitions(EXAMPLE_SERVER PRIVATE WEBSOCKET_CPP_API)
endif()
if(ENABLE_C_API)
target_compile_definitions(EXAMPLE_CLIENT PRIVATE WEBSOCKET_C_API)
target_compile_definitions(EXAMPLE_SERVER PRIVATE WEBSOCKET_C_API)
endif()
if(EXAMPLE_C_API)
target_compile_definitions(EXAMPLE_CLIENT PRIVATE WEBSOCKET_EXAMPLE_C_API)
target_compile_definitions(EXAMPLE_SERVER PRIVATE WEBSOCKET_EXAMPLE_C_API)
endif()
if(WIN32)
target_link_libraries(EXAMPLE_CLIENT wsock32 ws2_32)
target_link_libraries(EXAMPLE_SERVER wsock32 ws2_32)
endif()
endif()