CMakeLists.txt revision 8ecb980d
1# Copyright (c) 2017 - 2021 LiteSpeed Technologies Inc.  See LICENSE.
2LIST(APPEND LIBS ${EVENT_LIB})
3
4IF(MSVC)
5    FIND_LIBRARY(PCRE_LIB pcre)
6    IF(PCRE_LIB)
7        MESSAGE(STATUS "Found pcre: ${PCRE_LIB}")
8        LIST(APPEND LIBS ${PCRE_LIB})
9    ELSE()
10        MESSAGE(STATUS "pcre not found: http_server won't work")
11    ENDIF()
12    FIND_LIBRARY(PCREPOSIX_LIB pcreposix)
13    IF(PCREPOSIX_LIB)
14        MESSAGE(STATUS "Found pcreposix: ${PCREPOSIX_LIB}")
15        LIST(APPEND LIBS ${PCREPOSIX_LIB})
16    ELSE()
17        MESSAGE(STATUS "pcreposix not found: http_server won't work")
18    ENDIF()
19    LIST(APPEND LIBS ws2_32)
20    LIST(APPEND LIBS iphlpapi)
21ENDIF()
22
23IF(MSVC)
24    SET(GETOPT_C ../wincompat/getopt.c)
25ENDIF()
26add_executable(http_server http_server.c prog.c test_common.c test_cert.c ${GETOPT_C})
27IF(NOT MSVC)   #   TODO: port MD5 server and client to Windows
28add_executable(md5_server md5_server.c prog.c test_common.c test_cert.c ${GETOPT_C})
29add_executable(md5_client md5_client.c prog.c test_common.c test_cert.c ${GETOPT_C})
30ENDIF()
31add_executable(echo_server echo_server.c prog.c test_common.c test_cert.c ${GETOPT_C})
32add_executable(echo_client echo_client.c prog.c test_common.c test_cert.c ${GETOPT_C})
33add_executable(duck_server duck_server.c prog.c test_common.c test_cert.c ${GETOPT_C})
34add_executable(duck_client duck_client.c prog.c test_common.c test_cert.c ${GETOPT_C})
35add_executable(perf_client perf_client.c prog.c test_common.c test_cert.c ${GETOPT_C})
36add_executable(perf_server perf_server.c prog.c test_common.c test_cert.c ${GETOPT_C})
37
38
39IF (NOT MSVC)
40
41add_executable(http_client
42    http_client.c
43    prog.c
44    test_common.c
45    test_cert.c
46)
47
48#MSVC
49ELSE()
50
51add_executable(http_client
52    http_client.c
53    prog.c
54    test_common.c
55    test_cert.c
56    ../wincompat/getopt.c
57    ../wincompat/getopt1.c
58)
59
60ENDIF()
61
62TARGET_LINK_LIBRARIES(http_client ${LIBS})
63TARGET_LINK_LIBRARIES(http_server ${LIBS})
64IF(NOT MSVC)
65TARGET_LINK_LIBRARIES(md5_server  ${LIBS})
66TARGET_LINK_LIBRARIES(md5_client  ${LIBS})
67ENDIF()
68TARGET_LINK_LIBRARIES(echo_server ${LIBS})
69TARGET_LINK_LIBRARIES(echo_client ${LIBS})
70TARGET_LINK_LIBRARIES(duck_server ${LIBS})
71TARGET_LINK_LIBRARIES(duck_client ${LIBS})
72TARGET_LINK_LIBRARIES(perf_client ${LIBS})
73TARGET_LINK_LIBRARIES(perf_server ${LIBS})
74
75
76INCLUDE(CheckFunctionExists)
77CHECK_FUNCTION_EXISTS(sendmmsg HAVE_SENDMMSG)
78CHECK_FUNCTION_EXISTS(recvmmsg HAVE_RECVMMSG)
79CHECK_FUNCTION_EXISTS(open_memstream HAVE_OPEN_MEMSTREAM)
80
81
82INCLUDE(CheckSymbolExists)
83
84CHECK_SYMBOL_EXISTS(
85    IP_MTU_DISCOVER
86    "netinet/in.h"
87    HAVE_IP_MTU_DISCOVER
88)
89
90CHECK_SYMBOL_EXISTS(
91    IP_DONTFRAG
92    "netinet/in.h"
93    HAVE_IP_DONTFRAG
94)
95
96CHECK_SYMBOL_EXISTS(
97    preadv
98    "sys/uio.h"
99    HAVE_PREADV
100)
101
102INCLUDE(CheckIncludeFiles)
103
104IF (MSVC AND PCRE_LIB)
105FIND_PATH(EVENT_INCLUDE_DIR NAMES pcreposix.h)
106IF (EVENT_INCLUDE_DIR)
107    MESSAGE(STATUS "found pcreposix.h")
108    SET(HAVE_REGEX 1)
109ELSE()
110    MESSAGE(FATAL_ERROR "event2/event.h was not found")
111ENDIF()
112ELSE()
113CHECK_INCLUDE_FILES(regex.h HAVE_REGEX)
114ENDIF()
115
116CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test_config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/test_config.h)
117