summaryrefslogtreecommitdiffstats
path: root/examples/CMakeLists.txt
blob: 09701b80eced768140ec8f2664d3bcd688af91b6 (plain)
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
# ngtcp2

# Copyright (c) 2017 ngtcp2 contributors

# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:

# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

if(LIBEV_FOUND AND HAVE_OPENSSL AND LIBNGHTTP3_FOUND)
  set(client_SOURCES
    client.cc
    client_base.cc
    debug.cc
    util.cc
    shared.cc
    tls_client_context_openssl.cc
    tls_client_session_openssl.cc
    tls_session_base_openssl.cc
    util_openssl.cc
  )

  set(server_SOURCES
    server.cc
    server_base.cc
    debug.cc
    util.cc
    http.cc
    shared.cc
    tls_server_context_openssl.cc
    tls_server_session_openssl.cc
    tls_session_base_openssl.cc
    util_openssl.cc
  )

  set(ossl_INCLUDE_DIRS
    ${CMAKE_SOURCE_DIR}/lib/includes
    ${CMAKE_BINARY_DIR}/lib/includes
    ${CMAKE_SOURCE_DIR}/third-party
    ${CMAKE_SOURCE_DIR}/crypto/includes

    ${JEMALLOC_INCLUDE_DIRS}
    ${OPENSSL_INCLUDE_DIRS}
    ${LIBEV_INCLUDE_DIRS}
    ${LIBNGHTTP3_INCLUDE_DIRS}
  )

  set(ossl_LIBS
    ngtcp2_crypto_openssl
    ngtcp2
    ${JEMALLOC_LIBRARIES}
    ${OPENSSL_LIBRARIES}
    ${LIBEV_LIBRARIES}
    ${LIBNGHTTP3_LIBRARIES}
  )

  add_executable(client ${client_SOURCES} $<TARGET_OBJECTS:http-parser>)
  add_executable(server ${server_SOURCES} $<TARGET_OBJECTS:http-parser>)
  set_target_properties(client PROPERTIES
    COMPILE_FLAGS "${WARNCXXFLAGS} -DENABLE_EXAMPLE_OPENSSL -DWITH_EXAMPLE_OPENSSL"
    CXX_STANDARD 20
    CXX_STANDARD_REQUIRED ON
  )
  set_target_properties(server PROPERTIES
    COMPILE_FLAGS "${WARNCXXFLAGS} -DENABLE_EXAMPLE_OPENSSL -DWITH_EXAMPLE_OPENSSL"
    CXX_STANDARD 20
    CXX_STANDARD_REQUIRED ON
  )
  target_include_directories(client PUBLIC ${ossl_INCLUDE_DIRS})
  target_include_directories(server PUBLIC ${ossl_INCLUDE_DIRS})
  target_link_libraries(client ${ossl_LIBS})
  target_link_libraries(server ${ossl_LIBS})

  # TODO prevent client and example servers from being installed?
endif()

if(LIBEV_FOUND AND HAVE_GNUTLS AND LIBNGHTTP3_FOUND)
  set(gtlsclient_SOURCES
    client.cc
    client_base.cc
    debug.cc
    util.cc
    shared.cc
    tls_client_context_gnutls.cc
    tls_client_session_gnutls.cc
    tls_session_base_gnutls.cc
    util_gnutls.cc
  )

  set(gtlsserver_SOURCES
    server.cc
    server_base.cc
    debug.cc
    util.cc
    http.cc
    shared.cc
    tls_server_context_gnutls.cc
    tls_server_session_gnutls.cc
    tls_session_base_gnutls.cc
    util_gnutls.cc
  )

  set(gtls_INCLUDE_DIRS
    ${CMAKE_SOURCE_DIR}/lib/includes
    ${CMAKE_BINARY_DIR}/lib/includes
    ${CMAKE_SOURCE_DIR}/third-party
    ${CMAKE_SOURCE_DIR}/crypto/includes

    ${JEMALLOC_INCLUDE_DIRS}
    ${GNUTLS_INCLUDE_DIRS}
    ${LIBEV_INCLUDE_DIRS}
    ${LIBNGHTTP3_INCLUDE_DIRS}
  )

  set(gtls_LIBS
    ngtcp2_crypto_gnutls
    ngtcp2
    ${JEMALLOC_LIBRARIES}
    ${GNUTLS_LIBRARIES}
    ${LIBEV_LIBRARIES}
    ${LIBNGHTTP3_LIBRARIES}
  )

  add_executable(gtlsclient ${gtlsclient_SOURCES} $<TARGET_OBJECTS:http-parser>)
  add_executable(gtlsserver ${gtlsserver_SOURCES} $<TARGET_OBJECTS:http-parser>)
  set_target_properties(gtlsclient PROPERTIES
    COMPILE_FLAGS "${WARNCXXFLAGS} -DENABLE_EXAMPLE_GNUTLS -DWITH_EXAMPLE_GNUTLS"
    CXX_STANDARD 20
    CXX_STANDARD_REQUIRED ON
  )
  set_target_properties(gtlsserver PROPERTIES
    COMPILE_FLAGS "${WARNCXXFLAGS} -DENABLE_EXAMPLE_GNUTLS -DWITH_EXAMPLE_GNUTLS"
    CXX_STANDARD 20
    CXX_STANDARD_REQUIRED ON
  )
  target_include_directories(gtlsclient PUBLIC ${gtls_INCLUDE_DIRS})
  target_include_directories(gtlsserver PUBLIC ${gtls_INCLUDE_DIRS})
  target_link_libraries(gtlsclient ${gtls_LIBS})
  target_link_libraries(gtlsserver ${gtls_LIBS})

  # TODO prevent gtlsclient and example gtlsservers from being installed?
endif()

if(LIBEV_FOUND AND HAVE_BORINGSSL AND LIBNGHTTP3_FOUND)
  set(bsslclient_SOURCES
    client.cc
    client_base.cc
    debug.cc
    util.cc
    shared.cc
    tls_client_context_boringssl.cc
    tls_client_session_boringssl.cc
    tls_session_base_openssl.cc
    util_openssl.cc
  )

  set(bsslserver_SOURCES
    server.cc
    server_base.cc
    debug.cc
    util.cc
    http.cc
    shared.cc
    tls_server_context_boringssl.cc
    tls_server_session_boringssl.cc
    tls_session_base_openssl.cc
    util_openssl.cc
  )

  set(bssl_INCLUDE_DIRS
    ${CMAKE_SOURCE_DIR}/lib/includes
    ${CMAKE_BINARY_DIR}/lib/includes
    ${CMAKE_SOURCE_DIR}/third-party
    ${CMAKE_SOURCE_DIR}/crypto/includes

    ${JEMALLOC_INCLUDE_DIRS}
    ${BORINGSSL_INCLUDE_DIRS}
    ${LIBEV_INCLUDE_DIRS}
    ${LIBNGHTTP3_INCLUDE_DIRS}
  )

  set(bssl_LIBS
    ngtcp2_crypto_boringssl_static
    ngtcp2
    ${JEMALLOC_LIBRARIES}
    ${BORINGSSL_LIBRARIES}
    ${LIBEV_LIBRARIES}
    ${LIBNGHTTP3_LIBRARIES}
  )

  add_executable(bsslclient ${bsslclient_SOURCES} $<TARGET_OBJECTS:http-parser>)
  add_executable(bsslserver ${bsslserver_SOURCES} $<TARGET_OBJECTS:http-parser>)
  set_target_properties(bsslclient PROPERTIES
    COMPILE_FLAGS "${WARNCXXFLAGS} -DENABLE_EXAMPLE_BORINGSSL -DWITH_EXAMPLE_BORINGSSL"
    CXX_STANDARD 20
    CXX_STANDARD_REQUIRED ON
  )
  set_target_properties(bsslserver PROPERTIES
    COMPILE_FLAGS "${WARNCXXFLAGS} -DENABLE_EXAMPLE_BORINGSSL -DWITH_EXAMPLE_BORINGSSL"
    CXX_STANDARD 20
    CXX_STANDARD_REQUIRED ON
  )
  target_include_directories(bsslclient PUBLIC ${bssl_INCLUDE_DIRS})
  target_include_directories(bsslserver PUBLIC ${bssl_INCLUDE_DIRS})
  target_link_libraries(bsslclient ${bssl_LIBS})
  target_link_libraries(bsslserver ${bssl_LIBS})

  # TODO prevent bsslclient and example bsslservers from being installed?
endif()

if(LIBEV_FOUND AND HAVE_PICOTLS AND LIBNGHTTP3_FOUND)
  set(ptlsclient_SOURCES
    client.cc
    client_base.cc
    debug.cc
    util.cc
    shared.cc
    tls_client_context_picotls.cc
    tls_client_session_picotls.cc
    tls_session_base_picotls.cc
    util_openssl.cc
  )

  set(ptlsserver_SOURCES
    server.cc
    server_base.cc
    debug.cc
    util.cc
    http.cc
    shared.cc
    tls_server_context_picotls.cc
    tls_server_session_picotls.cc
    tls_session_base_picotls.cc
    util_openssl.cc
  )

  set(ptls_INCLUDE_DIRS
    ${CMAKE_SOURCE_DIR}/lib/includes
    ${CMAKE_BINARY_DIR}/lib/includes
    ${CMAKE_SOURCE_DIR}/third-party
    ${CMAKE_SOURCE_DIR}/crypto/includes

    ${JEMALLOC_INCLUDE_DIRS}
    ${PICOTLS_INCLUDE_DIRS}
    ${VANILLA_OPENSSL_INCLUDE_DIRS}
    ${LIBEV_INCLUDE_DIRS}
    ${LIBNGHTTP3_INCLUDE_DIRS}
  )

  set(ptls_LIBS
    ngtcp2_crypto_picotls_static
    ngtcp2
    ${JEMALLOC_LIBRARIES}
    ${PICOTLS_LIBRARIES}
    ${VANILLA_OPENSSL_LIBRARIES}
    ${LIBEV_LIBRARIES}
    ${LIBNGHTTP3_LIBRARIES}
  )

  add_executable(ptlsclient ${ptlsclient_SOURCES} $<TARGET_OBJECTS:http-parser>)
  add_executable(ptlsserver ${ptlsserver_SOURCES} $<TARGET_OBJECTS:http-parser>)
  set_target_properties(ptlsclient PROPERTIES
    COMPILE_FLAGS "${WARNCXXFLAGS} -DENABLE_EXAMPLE_PICOTLS -DWITH_EXAMPLE_PICOTLS"
    CXX_STANDARD 20
    CXX_STANDARD_REQUIRED ON
  )
  set_target_properties(ptlsserver PROPERTIES
    COMPILE_FLAGS "${WARNCXXFLAGS} -DENABLE_EXAMPLE_PICOTLS -DWITH_EXAMPLE_PICOTLS"
    CXX_STANDARD 20
    CXX_STANDARD_REQUIRED ON
  )
  target_include_directories(ptlsclient PUBLIC ${ptls_INCLUDE_DIRS})
  target_include_directories(ptlsserver PUBLIC ${ptls_INCLUDE_DIRS})
  target_link_libraries(ptlsclient ${ptls_LIBS})
  target_link_libraries(ptlsserver ${ptls_LIBS})

  # TODO prevent ptlsclient and example ptlsservers from being installed?
endif()

if(LIBEV_FOUND AND HAVE_WOLFSSL AND LIBNGHTTP3_FOUND)
  set(wsslclient_SOURCES
    client.cc
    client_base.cc
    debug.cc
    util.cc
    shared.cc
    tls_client_context_wolfssl.cc
    tls_client_session_wolfssl.cc
    tls_session_base_wolfssl.cc
    util_wolfssl.cc
  )

  set(wsslserver_SOURCES
    server.cc
    server_base.cc
    debug.cc
    util.cc
    http.cc
    shared.cc
    tls_server_context_wolfssl.cc
    tls_server_session_wolfssl.cc
    tls_session_base_wolfssl.cc
    util_wolfssl.cc
  )

  set(wolfssl_INCLUDE_DIRS
    ${CMAKE_SOURCE_DIR}/lib/includes
    ${CMAKE_BINARY_DIR}/lib/includes
    ${CMAKE_SOURCE_DIR}/third-party
    ${CMAKE_SOURCE_DIR}/crypto/includes

    ${JEMALLOC_INCLUDE_DIRS}
    ${WOLFSSL_INCLUDE_DIRS}
    ${LIBEV_INCLUDE_DIRS}
    ${LIBNGHTTP3_INCLUDE_DIRS}
  )

  set(wolfssl_LIBS
    ngtcp2_crypto_wolfssl_static
    ngtcp2
    ${JEMALLOC_LIBRARIES}
    ${WOLFSSL_LIBRARIES}
    ${LIBEV_LIBRARIES}
    ${LIBNGHTTP3_LIBRARIES}
  )

  add_executable(wsslclient ${wsslclient_SOURCES} $<TARGET_OBJECTS:http-parser>)
  add_executable(wsslserver ${wsslserver_SOURCES} $<TARGET_OBJECTS:http-parser>)
  set_target_properties(wsslclient PROPERTIES
    COMPILE_FLAGS "${WARNCXXFLAGS} -DENABLE_EXAMPLE_WOLFSSL -DWITH_EXAMPLE_WOLFSSL"
    CXX_STANDARD 20
    CXX_STANDARD_REQUIRED ON
  )
  set_target_properties(wsslserver PROPERTIES
    COMPILE_FLAGS "${WARNCXXFLAGS} -DENABLE_EXAMPLE_WOLFSSL -DWITH_EXAMPLE_WOLFSSL"
    CXX_STANDARD 20
    CXX_STANDARD_REQUIRED ON
  )
  target_include_directories(wsslclient PUBLIC ${wolfssl_INCLUDE_DIRS})
  target_include_directories(wsslserver PUBLIC ${wolfssl_INCLUDE_DIRS})
  target_link_libraries(wsslclient ${wolfssl_LIBS})
  target_link_libraries(wsslserver ${wolfssl_LIBS})

  # TODO prevent wsslclient and example wsslserver from being installed?
endif()