CMakeLists.txt revision 8ecb980d
106b2a236SDmitri Tikhonov# Copyright (c) 2017 - 2021 LiteSpeed Technologies Inc.  See LICENSE.
2b54d1e63SDmitri TikhonovLIST(APPEND LIBS ${EVENT_LIB})
3b54d1e63SDmitri Tikhonov
4b54d1e63SDmitri TikhonovIF(MSVC)
5b54d1e63SDmitri Tikhonov    FIND_LIBRARY(PCRE_LIB pcre)
6b54d1e63SDmitri Tikhonov    IF(PCRE_LIB)
7b54d1e63SDmitri Tikhonov        MESSAGE(STATUS "Found pcre: ${PCRE_LIB}")
8b54d1e63SDmitri Tikhonov        LIST(APPEND LIBS ${PCRE_LIB})
9b54d1e63SDmitri Tikhonov    ELSE()
10b54d1e63SDmitri Tikhonov        MESSAGE(STATUS "pcre not found: http_server won't work")
11b54d1e63SDmitri Tikhonov    ENDIF()
12b54d1e63SDmitri Tikhonov    FIND_LIBRARY(PCREPOSIX_LIB pcreposix)
13b54d1e63SDmitri Tikhonov    IF(PCREPOSIX_LIB)
14b54d1e63SDmitri Tikhonov        MESSAGE(STATUS "Found pcreposix: ${PCREPOSIX_LIB}")
15b54d1e63SDmitri Tikhonov        LIST(APPEND LIBS ${PCREPOSIX_LIB})
16b54d1e63SDmitri Tikhonov    ELSE()
17b54d1e63SDmitri Tikhonov        MESSAGE(STATUS "pcreposix not found: http_server won't work")
18b54d1e63SDmitri Tikhonov    ENDIF()
19b54d1e63SDmitri Tikhonov    LIST(APPEND LIBS ws2_32)
20b54d1e63SDmitri Tikhonov    LIST(APPEND LIBS iphlpapi)
21b54d1e63SDmitri TikhonovENDIF()
22b54d1e63SDmitri Tikhonov
23b54d1e63SDmitri TikhonovIF(MSVC)
24b54d1e63SDmitri Tikhonov    SET(GETOPT_C ../wincompat/getopt.c)
25b54d1e63SDmitri TikhonovENDIF()
26b54d1e63SDmitri Tikhonovadd_executable(http_server http_server.c prog.c test_common.c test_cert.c ${GETOPT_C})
27b54d1e63SDmitri TikhonovIF(NOT MSVC)   #   TODO: port MD5 server and client to Windows
28b54d1e63SDmitri Tikhonovadd_executable(md5_server md5_server.c prog.c test_common.c test_cert.c ${GETOPT_C})
29b54d1e63SDmitri Tikhonovadd_executable(md5_client md5_client.c prog.c test_common.c test_cert.c ${GETOPT_C})
30b54d1e63SDmitri TikhonovENDIF()
31b54d1e63SDmitri Tikhonovadd_executable(echo_server echo_server.c prog.c test_common.c test_cert.c ${GETOPT_C})
32b54d1e63SDmitri Tikhonovadd_executable(echo_client echo_client.c prog.c test_common.c test_cert.c ${GETOPT_C})
33b54d1e63SDmitri Tikhonovadd_executable(duck_server duck_server.c prog.c test_common.c test_cert.c ${GETOPT_C})
34b54d1e63SDmitri Tikhonovadd_executable(duck_client duck_client.c prog.c test_common.c test_cert.c ${GETOPT_C})
358ecb980dSDmitri Tikhonovadd_executable(perf_client perf_client.c prog.c test_common.c test_cert.c ${GETOPT_C})
368ecb980dSDmitri Tikhonovadd_executable(perf_server perf_server.c prog.c test_common.c test_cert.c ${GETOPT_C})
37b54d1e63SDmitri Tikhonov
38b54d1e63SDmitri Tikhonov
39b54d1e63SDmitri TikhonovIF (NOT MSVC)
40b54d1e63SDmitri Tikhonov
41b54d1e63SDmitri Tikhonovadd_executable(http_client
42b54d1e63SDmitri Tikhonov    http_client.c
43b54d1e63SDmitri Tikhonov    prog.c
44b54d1e63SDmitri Tikhonov    test_common.c
45b54d1e63SDmitri Tikhonov    test_cert.c
46b54d1e63SDmitri Tikhonov)
47b54d1e63SDmitri Tikhonov
48b54d1e63SDmitri Tikhonov#MSVC
49b54d1e63SDmitri TikhonovELSE()
50b54d1e63SDmitri Tikhonov
51b54d1e63SDmitri Tikhonovadd_executable(http_client
52b54d1e63SDmitri Tikhonov    http_client.c
53b54d1e63SDmitri Tikhonov    prog.c
54b54d1e63SDmitri Tikhonov    test_common.c
55b54d1e63SDmitri Tikhonov    test_cert.c
56b54d1e63SDmitri Tikhonov    ../wincompat/getopt.c
57b54d1e63SDmitri Tikhonov    ../wincompat/getopt1.c
58b54d1e63SDmitri Tikhonov)
59b54d1e63SDmitri Tikhonov
60b54d1e63SDmitri TikhonovENDIF()
61b54d1e63SDmitri Tikhonov
62b54d1e63SDmitri TikhonovTARGET_LINK_LIBRARIES(http_client ${LIBS})
63b54d1e63SDmitri TikhonovTARGET_LINK_LIBRARIES(http_server ${LIBS})
64b54d1e63SDmitri TikhonovIF(NOT MSVC)
65b54d1e63SDmitri TikhonovTARGET_LINK_LIBRARIES(md5_server  ${LIBS})
66b54d1e63SDmitri TikhonovTARGET_LINK_LIBRARIES(md5_client  ${LIBS})
67b54d1e63SDmitri TikhonovENDIF()
68b54d1e63SDmitri TikhonovTARGET_LINK_LIBRARIES(echo_server ${LIBS})
69b54d1e63SDmitri TikhonovTARGET_LINK_LIBRARIES(echo_client ${LIBS})
70b54d1e63SDmitri TikhonovTARGET_LINK_LIBRARIES(duck_server ${LIBS})
71b54d1e63SDmitri TikhonovTARGET_LINK_LIBRARIES(duck_client ${LIBS})
728ecb980dSDmitri TikhonovTARGET_LINK_LIBRARIES(perf_client ${LIBS})
738ecb980dSDmitri TikhonovTARGET_LINK_LIBRARIES(perf_server ${LIBS})
74b54d1e63SDmitri Tikhonov
75b54d1e63SDmitri Tikhonov
765392f7a3SLiteSpeed TechINCLUDE(CheckFunctionExists)
775392f7a3SLiteSpeed TechCHECK_FUNCTION_EXISTS(sendmmsg HAVE_SENDMMSG)
785392f7a3SLiteSpeed TechCHECK_FUNCTION_EXISTS(recvmmsg HAVE_RECVMMSG)
795392f7a3SLiteSpeed TechCHECK_FUNCTION_EXISTS(open_memstream HAVE_OPEN_MEMSTREAM)
805392f7a3SLiteSpeed Tech
8150aadb33SDmitri Tikhonov
82e0197994SDmitri TikhonovINCLUDE(CheckSymbolExists)
83e0197994SDmitri Tikhonov
84e0197994SDmitri TikhonovCHECK_SYMBOL_EXISTS(
85e0197994SDmitri Tikhonov    IP_MTU_DISCOVER
86e0197994SDmitri Tikhonov    "netinet/in.h"
87e0197994SDmitri Tikhonov    HAVE_IP_MTU_DISCOVER
88e0197994SDmitri Tikhonov)
89e0197994SDmitri Tikhonov
90e0197994SDmitri TikhonovCHECK_SYMBOL_EXISTS(
91e0197994SDmitri Tikhonov    IP_DONTFRAG
92e0197994SDmitri Tikhonov    "netinet/in.h"
93e0197994SDmitri Tikhonov    HAVE_IP_DONTFRAG
94e0197994SDmitri Tikhonov)
95e0197994SDmitri Tikhonov
96c3c69ba3SDmitri TikhonovCHECK_SYMBOL_EXISTS(
97c3c69ba3SDmitri Tikhonov    preadv
98c3c69ba3SDmitri Tikhonov    "sys/uio.h"
99c3c69ba3SDmitri Tikhonov    HAVE_PREADV
100c3c69ba3SDmitri Tikhonov)
101c3c69ba3SDmitri Tikhonov
1025dc94445SDmitri TikhonovINCLUDE(CheckIncludeFiles)
1035dc94445SDmitri Tikhonov
104fb3e20e0SDmitri TikhonovIF (MSVC AND PCRE_LIB)
105fb3e20e0SDmitri TikhonovFIND_PATH(EVENT_INCLUDE_DIR NAMES pcreposix.h)
106fb3e20e0SDmitri TikhonovIF (EVENT_INCLUDE_DIR)
107fb3e20e0SDmitri Tikhonov    MESSAGE(STATUS "found pcreposix.h")
108fb3e20e0SDmitri Tikhonov    SET(HAVE_REGEX 1)
109fb3e20e0SDmitri TikhonovELSE()
110fb3e20e0SDmitri Tikhonov    MESSAGE(FATAL_ERROR "event2/event.h was not found")
111fb3e20e0SDmitri TikhonovENDIF()
112fb3e20e0SDmitri TikhonovELSE()
1135dc94445SDmitri TikhonovCHECK_INCLUDE_FILES(regex.h HAVE_REGEX)
114fb3e20e0SDmitri TikhonovENDIF()
115e0197994SDmitri Tikhonov
116e0197994SDmitri TikhonovCONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test_config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/test_config.h)
117