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