@@ -17,9 +17,40 @@ if(NOT SSL_TYPE)
17
17
set (SSL_TYPE "babassl" )
18
18
endif ()
19
19
20
- # PATH of ssl
21
- if (NOT SSL_PATH)
22
- set (SSL_PATH "/usr/local/babassl" )
20
+ if (${SSL_TYPE} MATCHES "babassl" )
21
+ # PATH of ssl
22
+ if (NOT SSL_PATH)
23
+ set (SSL_PATH "/usr/local/babassl" )
24
+ endif ()
25
+
26
+ # ssl lib denpendency
27
+ if (NOT SSL_LIB_PATH)
28
+ set (SSL_LIB_PATH
29
+ ${SSL_PATH} /lib/libssl.a
30
+ ${SSL_PATH} /lib/libcrypto.a
31
+ )
32
+ endif ()
33
+ elseif (${SSL_TYPE} MATCHES "boringssl" )
34
+ # PATH of ssl
35
+ if (NOT SSL_PATH)
36
+ set (SSL_PATH ${CMAKE_CURRENT_SOURCE_DIR} /third_party/boringssl)
37
+ endif ()
38
+
39
+ # ssl lib denpendency
40
+ if (NOT SSL_LIB_PATH)
41
+ if (CMAKE_SYSTEM_NAME MATCHES "Windows" )
42
+ add_definitions (-DNOCRYPT=1)
43
+ set (SSL_LIB_PATH
44
+ ${SSL_PATH} /build /ssl/${CMAKE_BUILD_TYPE} /ssl.lib
45
+ ${SSL_PATH} /build /crypto/${CMAKE_BUILD_TYPE} /crypto.lib
46
+ )
47
+ else ()
48
+ set (SSL_LIB_PATH
49
+ ${SSL_PATH} /build /ssl/libssl.a
50
+ ${SSL_PATH} /build /crypto/libcrypto.a
51
+ )
52
+ endif ()
53
+ endif ()
23
54
endif ()
24
55
25
56
# ssl include path
@@ -29,13 +60,10 @@ if(NOT SSL_INC_PATH)
29
60
)
30
61
endif ()
31
62
32
- # ssl lib denpendency
33
- if (NOT SSL_LIB_PATH)
34
- set (SSL_LIB_PATH
35
- ${SSL_PATH} /lib/libssl.a
36
- ${SSL_PATH} /lib/libcrypto.a
37
- )
38
- endif ()
63
+ MESSAGE ("SSL_TYPE= ${SSL_TYPE} " )
64
+ MESSAGE ("SSL_PATH= ${SSL_PATH} " )
65
+ MESSAGE ("SSL_LIB_PATH= ${SSL_LIB_PATH} " )
66
+ MESSAGE ("SSL_INC_PATH= ${SSL_INC_PATH} " )
39
67
40
68
# print tls traffic secret in keylog
41
69
if (XQC_PRINT_SECRET)
@@ -65,8 +93,15 @@ endif()
65
93
66
94
67
95
# C_FLAGS
68
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O2 -std=gnu11 -Werror -Wall -Wno-unused -Wno-pointer-sign -Wno-format-security -DNDEBUG_PRINT -DNPRINT_MALLOC " )
69
- set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -O0 -std=gnu11 -Werror -Wall -Wno-unused -Wno-pointer-sign -Wno-format-security -DNDEBUG_PRINT -DNPRINT_MALLOC -DXQC_DEBUG " )
96
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O2 -std=gnu11 -Wall -DNDEBUG_PRINT -DNPRINT_MALLOC " )
97
+ set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -O0 -std=gnu11 -Wall -DNDEBUG_PRINT -DNPRINT_MALLOC -DXQC_DEBUG " )
98
+
99
+ if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows" )
100
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wno-unused -Wno-pointer-sign -Wno-format-security " )
101
+ set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Werror -Wno-unused -Wno-pointer-sign -Wno-format-security " )
102
+ else ()
103
+ add_definitions (-DXQC_SYS_WINDOWS=1)
104
+ endif ()
70
105
71
106
# additional C_FLAGS on mac
72
107
if (PLATFORM STREQUAL "mac32" )
@@ -263,10 +298,9 @@ include_directories(${SSL_INC_PATH})
263
298
include_directories (${CMAKE_SOURCE_DIR} /)
264
299
265
300
266
-
267
301
##### build unittest, test client/server, demo client/server #####
268
302
if (XQC_ENABLE_TESTING)
269
- # CUnit
303
+ # CUnit TODO: fix test unit on windows
270
304
find_package (CUnit 2.1)
271
305
enable_testing ()
272
306
set (HAVE_CUNIT ${CUNIT_FOUND} )
@@ -275,10 +309,24 @@ if (XQC_ENABLE_TESTING)
275
309
endif ()
276
310
277
311
add_subdirectory (tests)
312
+ include_directories (${CMAKE_CURRENT_BINARY_DIR} /test )
313
+
314
+ if (CMAKE_SYSTEM_NAME MATCHES "Windows" )
315
+ # used wingetopt on windows
316
+ if (NOT GETOPT_INC_PATH)
317
+ set (GETOPT_INC_PATH
318
+ ${CMAKE_SOURCE_DIR} /third_party/wingetopt
319
+ )
320
+ endif ()
321
+ MESSAGE ("GETOPT_INC_PATH= ${GETOPT_INC_PATH} " )
322
+
323
+ include_directories (${GETOPT_INC_PATH} /src)
324
+ set (GETOPT_SOURCES "${GETOPT_INC_PATH} /src/getopt.c" )
325
+ endif ()
278
326
279
327
### test client/server ###
280
- add_executable (test_server tests/test_server.c)
281
- add_executable (test_client tests/test_client.c)
328
+ add_executable (test_server tests/test_server.c ${GETOPT_SOURCES} )
329
+ add_executable (test_client tests/test_client.c ${GETOPT_SOURCES} )
282
330
283
331
### hq demo client/server ###
284
332
set (
@@ -300,10 +348,24 @@ if (XQC_ENABLE_TESTING)
300
348
"demo/demo_server.c"
301
349
)
302
350
303
- add_executable (demo_server ${DEMO_SERVER_SOURCES} )
304
- add_executable (demo_client ${DEMO_CLIENT_SOURCES} )
305
-
306
- link_directories (/usr/local/lib)
351
+ add_executable (demo_server ${DEMO_SERVER_SOURCES} ${GETOPT_SOURCES} )
352
+ add_executable (demo_client ${DEMO_CLIENT_SOURCES} ${GETOPT_SOURCES} )
353
+ if (CMAKE_SYSTEM_NAME MATCHES "Windows" )
354
+ if (NOT EVENT_LIB_DIR)
355
+ message ("YOU NEED SET -DEVENT_LIB_DIR=your_event_path, eg:-DEVENT_LIB_DIR=D:/project/vcpkg/packages/libevent_x64-windows-static" )
356
+ endif ()
357
+
358
+ include_directories ( ${EVENT_LIB_DIR} /include )
359
+ link_directories ( ${EVENT_LIB_DIR} /lib )
360
+
361
+ SET (EVENT_LIB_PATH
362
+ ${EVENT_LIB_DIR} /lib/event.lib
363
+ ${EVENT_LIB_DIR} /lib/event_core.lib
364
+ ${EVENT_LIB_DIR} /lib/event_extra.lib
365
+ )
366
+ else ()
367
+ link_directories ( /usr/local/lib )
368
+ endif ()
307
369
308
370
if (PLATFORM STREQUAL "mac32" )
309
371
target_link_libraries (test_server xquic -lm ${CMAKE_CURRENT_SOURCE_DIR} /../libevent32/lib/libevent.dylib)
@@ -315,6 +377,11 @@ if (XQC_ENABLE_TESTING)
315
377
target_link_libraries (test_client xquic -lm -L/usr/local/lib -levent)
316
378
target_link_libraries (demo_server xquic -lm -L/usr/local/lib -levent)
317
379
target_link_libraries (demo_client xquic -lm -L/usr/local/lib -levent)
380
+ elseif (CMAKE_SYSTEM_NAME MATCHES "Windows" )
381
+ target_link_libraries (test_server xquic ${EVENT_LIB_PATH} -lm)
382
+ target_link_libraries (test_client xquic ${EVENT_LIB_PATH} -lm)
383
+ target_link_libraries (demo_server xquic ${EVENT_LIB_PATH} -lm)
384
+ target_link_libraries (demo_client xquic ${EVENT_LIB_PATH} -lm)
318
385
else ()
319
386
target_link_libraries (test_server xquic -levent -lm)
320
387
target_link_libraries (test_client xquic -levent -lm)
0 commit comments