CMakeLists.txt revision b54d1e63
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}) 35 36 37IF (NOT MSVC) 38 39add_executable(http_client 40 http_client.c 41 prog.c 42 test_common.c 43 test_cert.c 44) 45 46#MSVC 47ELSE() 48 49add_executable(http_client 50 http_client.c 51 prog.c 52 test_common.c 53 test_cert.c 54 ../wincompat/getopt.c 55 ../wincompat/getopt1.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}) 70 71 72INCLUDE(CheckFunctionExists) 73CHECK_FUNCTION_EXISTS(sendmmsg HAVE_SENDMMSG) 74CHECK_FUNCTION_EXISTS(recvmmsg HAVE_RECVMMSG) 75CHECK_FUNCTION_EXISTS(open_memstream HAVE_OPEN_MEMSTREAM) 76 77 78INCLUDE(CheckSymbolExists) 79 80CHECK_SYMBOL_EXISTS( 81 IP_MTU_DISCOVER 82 "netinet/in.h" 83 HAVE_IP_MTU_DISCOVER 84) 85 86CHECK_SYMBOL_EXISTS( 87 IP_DONTFRAG 88 "netinet/in.h" 89 HAVE_IP_DONTFRAG 90) 91 92CHECK_SYMBOL_EXISTS( 93 preadv 94 "sys/uio.h" 95 HAVE_PREADV 96) 97 98INCLUDE(CheckIncludeFiles) 99 100IF (MSVC AND PCRE_LIB) 101FIND_PATH(EVENT_INCLUDE_DIR NAMES pcreposix.h) 102IF (EVENT_INCLUDE_DIR) 103 MESSAGE(STATUS "found pcreposix.h") 104 SET(HAVE_REGEX 1) 105ELSE() 106 MESSAGE(FATAL_ERROR "event2/event.h was not found") 107ENDIF() 108ELSE() 109CHECK_INCLUDE_FILES(regex.h HAVE_REGEX) 110ENDIF() 111 112CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test_config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/test_config.h) 113