CMakeLists.txt revision b1a7c3f9
17d09751dSDmitri Tikhonov# Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc. See LICENSE. 250aadb33SDmitri Tikhonovcmake_minimum_required(VERSION 2.8) 350aadb33SDmitri Tikhonov 450aadb33SDmitri Tikhonov 5b1af35d6SDmitri TikhonovPROJECT(lsquic C) 6461e84d8SAmol Deshpande 79a690580SDmitri TikhonovOPTION(LSQUIC_FIU "Use Fault Injection in Userspace (FIU)" OFF) 89a690580SDmitri TikhonovOPTION(LSQUIC_BIN "Compile example binaries that use the library" ON) 99a690580SDmitri TikhonovOPTION(LSQUIC_TESTS "Compile library unit tests" ON) 109a690580SDmitri Tikhonov 1112693a01SDmitri TikhonovIF (CMAKE_SYSTEM_NAME STREQUAL "Linux") 1212693a01SDmitri Tikhonov # If using older glibc, need to link with -lrt. See clock_getres(2). 1312693a01SDmitri Tikhonov EXECUTE_PROCESS( 1412693a01SDmitri Tikhonov COMMAND ${PROJECT_SOURCE_DIR}/print-glibc-version.sh ${CMAKE_C_COMPILER} 1512693a01SDmitri Tikhonov OUTPUT_VARIABLE GLIBC_VERSION) 1612693a01SDmitri Tikhonov IF(NOT GLIBC_VERSION EQUAL "" AND GLIBC_VERSION VERSION_LESS 2.17) 1712693a01SDmitri Tikhonov SET(LIBS ${LIBS} rt) 1812693a01SDmitri Tikhonov ENDIF() 1921c6983aSRahul JadhavELSEIF (CMAKE_SYSTEM_NAME STREQUAL "Android") 2021c6983aSRahul Jadhav # for android-ndk >= r19b 2121c6983aSRahul Jadhav set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY "BOTH") 2221c6983aSRahul Jadhav set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE "BOTH") 2321c6983aSRahul Jadhav set(CMAKE_FIND_ROOT_PATH_MODE_PATH "BOTH") 24ccd74161SDmitri TikhonovENDIF() 25ccd74161SDmitri Tikhonov 261e75f938SDmitri TikhonovIF("${CMAKE_BUILD_TYPE}" STREQUAL "") 271e75f938SDmitri Tikhonov SET(CMAKE_BUILD_TYPE Debug) 2850aadb33SDmitri TikhonovENDIF() 2950aadb33SDmitri Tikhonov 301e75f938SDmitri TikhonovMESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}") 3150aadb33SDmitri Tikhonov 32a0e1aeeeSDmitri TikhonovIF (NOT "$ENV{EXTRA_CFLAGS}" MATCHES "-DLSQUIC_DEBUG_NEXT_ADV_TICK") 33a0e1aeeeSDmitri Tikhonov SET(MY_CMAKE_FLAGS "-DLSQUIC_DEBUG_NEXT_ADV_TICK=1") 34a0e1aeeeSDmitri TikhonovENDIF() 35b93f59beSBob Perper 3646a5b669SDmitri TikhonovIF (NOT MSVC) 37461e84d8SAmol Deshpande 3850aadb33SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wall -Wextra -Wno-unused-parameter") 3950aadb33SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -fno-omit-frame-pointer") 405392f7a3SLiteSpeed TechINCLUDE(CheckCCompilerFlag) 415392f7a3SLiteSpeed TechCHECK_C_COMPILER_FLAG(-Wno-implicit-fallthrough HAS_NO_IMPLICIT_FALLTHROUGH) 425392f7a3SLiteSpeed TechIF (HAS_NO_IMPLICIT_FALLTHROUGH) 435392f7a3SLiteSpeed Tech SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wno-implicit-fallthrough") 445392f7a3SLiteSpeed TechENDIF() 4550aadb33SDmitri Tikhonov 46e0197994SDmitri TikhonovIF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.3) 4750aadb33SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wno-missing-field-initializers") 4850aadb33SDmitri TikhonovENDIF() 495392f7a3SLiteSpeed Tech 50662de5e1SDmitri TikhonovIF(LSQUIC_FIU) 51662de5e1SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DFIU_ENABLE=1") 52662de5e1SDmitri Tikhonov SET(LIBS ${LIBS} fiu) 53662de5e1SDmitri TikhonovENDIF() 54662de5e1SDmitri Tikhonov 551e75f938SDmitri TikhonovIF(CMAKE_BUILD_TYPE STREQUAL "Debug") 5650aadb33SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -O0 -g3") 57db8ac9eeSDmitri Tikhonov IF(CMAKE_C_COMPILER MATCHES "clang" AND 5803e6b668SDmitri Tikhonov NOT "$ENV{TRAVIS}" MATCHES "^true$" AND 5903e6b668SDmitri Tikhonov NOT "$ENV{EXTRA_CFLAGS}" MATCHES "-fsanitize") 6050aadb33SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -fsanitize=address") 61d6937ddcSinitlife SET(LIBS ${LIBS} -fsanitize=address) 6250aadb33SDmitri Tikhonov ENDIF() 635392f7a3SLiteSpeed Tech # Uncomment to enable cleartext protocol mode (no crypto): 645392f7a3SLiteSpeed Tech #SET (MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_ENABLE_HANDSHAKE_DISABLE=1") 6550aadb33SDmitri TikhonovELSE() 6650aadb33SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -O3 -g0") 6750aadb33SDmitri Tikhonov # Comment out the following line to compile out debug messages: 6850aadb33SDmitri Tikhonov #SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_LOWEST_LOG_LEVEL=LSQ_LOG_INFO") 6950aadb33SDmitri TikhonovENDIF() 7050aadb33SDmitri Tikhonov 7167b0dc15SDmitri TikhonovIF(LSQUIC_PROFILE EQUAL 1) 7267b0dc15SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -g -pg") 7367b0dc15SDmitri TikhonovENDIF() 7467b0dc15SDmitri Tikhonov 7516a9b66aSDmitri TikhonovIF(LSQUIC_COVERAGE EQUAL 1) 7616a9b66aSDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -fprofile-arcs -ftest-coverage") 7716a9b66aSDmitri TikhonovENDIF() 7816a9b66aSDmitri Tikhonov 7950aadb33SDmitri TikhonovIF(MY_CMAKE_FLAGS MATCHES "fsanitize=address") 8050aadb33SDmitri Tikhonov MESSAGE(STATUS "AddressSanitizer is ON") 8150aadb33SDmitri TikhonovELSE() 8250aadb33SDmitri Tikhonov MESSAGE(STATUS "AddressSanitizer is OFF") 8350aadb33SDmitri TikhonovENDIF() 8450aadb33SDmitri Tikhonov 85461e84d8SAmol Deshpande#MSVC 86461e84d8SAmol DeshpandeELSE() 87fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4100") # unreferenced formal parameter 88fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4115") # unnamed type definition in parentheses 89fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4116") # named type definition in parentheses 90fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4146") # unary minus operator applied to unsigned type, result still unsigned 91fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4132") # const initialization 92fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4200") # zero-sized array 93fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4204") # non-constant aggregate initializer 94fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4244") # integer conversion 95fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4245") # conversion from 'int' to 'unsigned int', signed/unsigned mismatch 96fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4267") # integer conversion 972d296031SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4214") # nonstandard extension used: bit field types other than int 98fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4295") # array is too small to include a terminating null character 99fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4334") # result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) 100fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4456") # hide previous local declaration 101fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4459") # hide global declaration 102fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4706") # assignment within conditional expression 103461e84d8SAmol DeshpandeSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -W4 -WX -Zi -DWIN32_LEAN_AND_MEAN -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -I${CMAKE_CURRENT_SOURCE_DIR}/wincompat") 1041e75f938SDmitri TikhonovIF(CMAKE_BUILD_TYPE STREQUAL "Debug") 105b5d685fcSBob Perper SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Od") 106461e84d8SAmol Deshpande #SET (MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DFIU_ENABLE=1") 107ccd74161SDmitri Tikhonov #SET(LIBS ${LIBS} fiu) 108461e84d8SAmol DeshpandeELSE() 109b5d685fcSBob Perper SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Ox") 110461e84d8SAmol Deshpande # Comment out the following line to compile out debug messages: 111461e84d8SAmol Deshpande #SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_LOWEST_LOG_LEVEL=LSQ_LOG_INFO") 112461e84d8SAmol DeshpandeENDIF() 113461e84d8SAmol Deshpande 114461e84d8SAmol DeshpandeENDIF() #MSVC 115461e84d8SAmol Deshpande 11650aadb33SDmitri Tikhonovset(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_CMAKE_FLAGS} $ENV{EXTRA_CFLAGS}") 11750aadb33SDmitri Tikhonov 11850aadb33SDmitri TikhonovMESSAGE(STATUS "Compiler flags: ${CMAKE_C_FLAGS}") 11950aadb33SDmitri Tikhonov 120fb3e20e0SDmitri Tikhonovfind_package(Perl) 121fb3e20e0SDmitri TikhonovIF(NOT PERL_FOUND) 122fb3e20e0SDmitri Tikhonov MESSAGE(FATAL_ERROR "Perl not found -- need it to generate source code") 123fb3e20e0SDmitri TikhonovENDIF() 124fb3e20e0SDmitri Tikhonov 1258ca33e0eSDmitri TikhonovIF (NOT DEFINED BORINGSSL_INCLUDE AND DEFINED BORINGSSL_DIR) 1268ca33e0eSDmitri Tikhonov FIND_PATH(BORINGSSL_INCLUDE NAMES openssl/ssl.h 1278ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_DIR}/include 1288ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1298ca33e0eSDmitri TikhonovENDIF() 130b1af35d6SDmitri Tikhonov# This must be done before adding other include directories to take 131b1af35d6SDmitri Tikhonov# precedence over header files from other SSL installs. 1328ca33e0eSDmitri Tikhonov 1338ca33e0eSDmitri TikhonovIF (BORINGSSL_INCLUDE) 1348ca33e0eSDmitri Tikhonov MESSAGE(STATUS "BoringSSL include directory ${BORINGSSL_INCLUDE}") 1358ca33e0eSDmitri Tikhonov INCLUDE_DIRECTORIES(${BORINGSSL_INCLUDE}) 136b1af35d6SDmitri TikhonovELSE() 137b1af35d6SDmitri Tikhonov MESSAGE(FATAL_ERROR "BoringSSL headers not found") 138e0197994SDmitri TikhonovENDIF() 13950aadb33SDmitri Tikhonov 1408ca33e0eSDmitri TikhonovIF (NOT DEFINED BORINGSSL_LIB AND DEFINED BORINGSSL_DIR) 1418ca33e0eSDmitri Tikhonov FOREACH(LIB_NAME ssl crypto decrepit) 1428ca33e0eSDmitri Tikhonov IF (CMAKE_SYSTEM_NAME STREQUAL Windows) 1438ca33e0eSDmitri Tikhonov FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 1448ca33e0eSDmitri Tikhonov NAMES ${LIB_NAME} 1458ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_DIR}/${LIB_NAME} 146fb3e20e0SDmitri Tikhonov PATH_SUFFIXES Debug Release MinSizeRel RelWithDebInfo 1478ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1488ca33e0eSDmitri Tikhonov ELSE() 1498ca33e0eSDmitri Tikhonov FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 1508ca33e0eSDmitri Tikhonov NAMES lib${LIB_NAME}.a 1518ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_DIR}/${LIB_NAME} 1528ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1538ca33e0eSDmitri Tikhonov ENDIF() 1548ca33e0eSDmitri Tikhonov IF(BORINGSSL_LIB_${LIB_NAME}) 1558ca33e0eSDmitri Tikhonov MESSAGE(STATUS "Found ${LIB_NAME} library: ${BORINGSSL_LIB_${LIB_NAME}}") 1568ca33e0eSDmitri Tikhonov ELSE() 1578ca33e0eSDmitri Tikhonov MESSAGE(STATUS "${LIB_NAME} library not found") 1588ca33e0eSDmitri Tikhonov ENDIF() 1598ca33e0eSDmitri Tikhonov ENDFOREACH() 1608ca33e0eSDmitri Tikhonov 1618ca33e0eSDmitri TikhonovELSE() 1628ca33e0eSDmitri Tikhonov 1638ca33e0eSDmitri Tikhonov 1648ca33e0eSDmitri Tikhonov FOREACH(LIB_NAME ssl crypto decrepit) 1658ca33e0eSDmitri Tikhonov IF (CMAKE_SYSTEM_NAME STREQUAL Windows) 1668ca33e0eSDmitri Tikhonov FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 1678ca33e0eSDmitri Tikhonov NAMES ${LIB_NAME} 1688ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_LIB} 1698ca33e0eSDmitri Tikhonov PATH_SUFFIXES Debug Release MinSizeRel RelWithDebInfo 1708ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1718ca33e0eSDmitri Tikhonov ELSE() 1728ca33e0eSDmitri Tikhonov FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 1738ca33e0eSDmitri Tikhonov NAMES lib${LIB_NAME}.a 1748ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_LIB} 17581558c3fSRahul Jadhav PATH_SUFFIXES ${LIB_NAME} 1768ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1778ca33e0eSDmitri Tikhonov ENDIF() 1788ca33e0eSDmitri Tikhonov IF(BORINGSSL_LIB_${LIB_NAME}) 1798ca33e0eSDmitri Tikhonov MESSAGE(STATUS "Found ${BORINGSSL_LIB} library: ${BORINGSSL_LIB_${LIB_NAME}}") 1808ca33e0eSDmitri Tikhonov ELSE() 1818ca33e0eSDmitri Tikhonov MESSAGE(STATUS "${BORINGSSL_LIB} library not found") 1828ca33e0eSDmitri Tikhonov ENDIF() 1838ca33e0eSDmitri Tikhonov ENDFOREACH() 184461e84d8SAmol Deshpande 1858ca33e0eSDmitri TikhonovENDIF() 1868ca33e0eSDmitri Tikhonov 1878ca33e0eSDmitri TikhonovSET(CMAKE_INCLUDE_CURRENT_DIR ON) 18883506617SDmitri TikhonovINCLUDE_DIRECTORIES(include) 189b1af35d6SDmitri TikhonovIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin") 19050aadb33SDmitri Tikhonov # Find libevent on FreeBSD: 1918ca33e0eSDmitri Tikhonov include_directories( /usr/local/include ) 1928ca33e0eSDmitri Tikhonov link_directories( /usr/local/lib ) 193b1af35d6SDmitri TikhonovENDIF() 194b1af35d6SDmitri Tikhonov 195b1af35d6SDmitri Tikhonov# Find zlib and libevent header files and library files 196b1af35d6SDmitri Tikhonov# TODO: libevent is not strictly necessary to build the library. 197b1af35d6SDmitri TikhonovFIND_PATH(ZLIB_INCLUDE_DIR NAMES zlib.h) 198b1af35d6SDmitri TikhonovIF (ZLIB_INCLUDE_DIR) 199b1af35d6SDmitri Tikhonov INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) 200b1af35d6SDmitri TikhonovELSE() 201b1af35d6SDmitri Tikhonov MESSAGE(FATAL_ERROR "zlib.h was not found") 202b1af35d6SDmitri TikhonovENDIF() 203b1af35d6SDmitri TikhonovIF (CMAKE_SYSTEM_NAME STREQUAL Windows) 204b1af35d6SDmitri Tikhonov FIND_LIBRARY(ZLIB_LIB zlib) 205b1af35d6SDmitri TikhonovELSEIF(CMAKE_SYSTEM_NAME STREQUAL Darwin) 206b1af35d6SDmitri Tikhonov # XXX somehow FIND_LIBRARY() does not find zlib on Travis? 207b1af35d6SDmitri Tikhonov SET(ZLIB_LIB z) 208b1af35d6SDmitri TikhonovELSE() 209b1af35d6SDmitri Tikhonov FIND_LIBRARY(ZLIB_LIB libz.a) 210b1af35d6SDmitri TikhonovENDIF() 211b1af35d6SDmitri TikhonovIF(ZLIB_LIB) 212b1af35d6SDmitri Tikhonov MESSAGE(STATUS "Found zlib: ${ZLIB_LIB}") 213b1af35d6SDmitri TikhonovELSE() 214b1af35d6SDmitri Tikhonov MESSAGE(STATUS "zlib not found") 215b1af35d6SDmitri TikhonovENDIF() 2169a690580SDmitri Tikhonov 217fb3e20e0SDmitri TikhonovIF (LSQUIC_BIN OR LSQUIC_TESTS) 218b1af35d6SDmitri TikhonovFIND_PATH(EVENT_INCLUDE_DIR NAMES event2/event.h) 219b1af35d6SDmitri TikhonovIF (EVENT_INCLUDE_DIR) 220b1af35d6SDmitri Tikhonov INCLUDE_DIRECTORIES(${EVENT_INCLUDE_DIR}) 221b1af35d6SDmitri TikhonovELSE() 222b1af35d6SDmitri Tikhonov MESSAGE(FATAL_ERROR "event2/event.h was not found") 223b1af35d6SDmitri TikhonovENDIF() 224b1af35d6SDmitri TikhonovIF (CMAKE_SYSTEM_NAME STREQUAL Windows) 225b1af35d6SDmitri Tikhonov FIND_LIBRARY(EVENT_LIB event) 226b1af35d6SDmitri TikhonovELSE() 227747be414SDmitri Tikhonov FIND_LIBRARY(EVENT_LIB libevent.a) 228747be414SDmitri Tikhonov IF(NOT EVENT_LIB) 229747be414SDmitri Tikhonov FIND_LIBRARY(EVENT_LIB libevent.so) 230747be414SDmitri Tikhonov ENDIF() 231b1af35d6SDmitri TikhonovENDIF() 232b1af35d6SDmitri TikhonovIF(EVENT_LIB) 233b1af35d6SDmitri Tikhonov MESSAGE(STATUS "Found event: ${EVENT_LIB}") 234b1af35d6SDmitri TikhonovELSE() 235b1af35d6SDmitri Tikhonov MESSAGE(STATUS "libevent not found") 23650aadb33SDmitri TikhonovENDIF() 237fb3e20e0SDmitri TikhonovSET(LIBS lsquic ${EVENT_LIB} ${BORINGSSL_LIB_ssl} ${BORINGSSL_LIB_crypto} ${ZLIB_LIB} ${LIBS}) 238fb3e20e0SDmitri TikhonovIF(MSVC) 239fb3e20e0SDmitri TikhonovFIND_LIBRARY(PCRE_LIB pcre) 240fb3e20e0SDmitri TikhonovIF(PCRE_LIB) 241fb3e20e0SDmitri Tikhonov MESSAGE(STATUS "Found pcre: ${PCRE_LIB}") 242fb3e20e0SDmitri Tikhonov LIST(APPEND LIBS ${PCRE_LIB}) 243fb3e20e0SDmitri TikhonovELSE() 244fb3e20e0SDmitri Tikhonov MESSAGE(STATUS "pcre not found: http_server won't work") 245fb3e20e0SDmitri TikhonovENDIF() 246fb3e20e0SDmitri TikhonovFIND_LIBRARY(PCREPOSIX_LIB pcreposix) 247fb3e20e0SDmitri TikhonovIF(PCREPOSIX_LIB) 248fb3e20e0SDmitri Tikhonov MESSAGE(STATUS "Found pcreposix: ${PCREPOSIX_LIB}") 249fb3e20e0SDmitri Tikhonov LIST(APPEND LIBS ${PCREPOSIX_LIB}) 250fb3e20e0SDmitri TikhonovELSE() 251fb3e20e0SDmitri Tikhonov MESSAGE(STATUS "pcreposix not found: http_server won't work") 252fb3e20e0SDmitri TikhonovENDIF() 253fb3e20e0SDmitri TikhonovLIST(APPEND LIBS ws2_32) 254fb3e20e0SDmitri TikhonovENDIF() 255fb3e20e0SDmitri TikhonovENDIF() # LSQUIC_BIN OR LSQUIC_TESTS 25650aadb33SDmitri Tikhonov 257fb3e20e0SDmitri TikhonovIF(LSQUIC_BIN) 258fb3e20e0SDmitri TikhonovIF(MSVC) 259fb3e20e0SDmitri Tikhonov SET(GETOPT_C wincompat/getopt.c) 260fb3e20e0SDmitri TikhonovENDIF() 261fb3e20e0SDmitri Tikhonovadd_executable(http_server bin/http_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 262fb3e20e0SDmitri TikhonovIF(NOT MSVC) # TODO: port MD5 server and client to Windows 263fb3e20e0SDmitri Tikhonovadd_executable(md5_server bin/md5_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 264fb3e20e0SDmitri Tikhonovadd_executable(md5_client bin/md5_client.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 265fb3e20e0SDmitri TikhonovENDIF() 266fb3e20e0SDmitri Tikhonovadd_executable(echo_server bin/echo_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 267fb3e20e0SDmitri Tikhonovadd_executable(echo_client bin/echo_client.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 268b1a7c3f9SDmitri Tikhonovadd_executable(duck_server bin/duck_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 269b1a7c3f9SDmitri Tikhonovadd_executable(duck_client bin/duck_client.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 2708ca33e0eSDmitri Tikhonov 271b93f59beSBob Perper 27246a5b669SDmitri TikhonovIF (NOT MSVC) 2735392f7a3SLiteSpeed Tech 274c51ce338SDmitri Tikhonovadd_executable(http_client 2759a690580SDmitri Tikhonov bin/http_client.c 2769a690580SDmitri Tikhonov bin/prog.c 2779a690580SDmitri Tikhonov bin/test_common.c 2789a690580SDmitri Tikhonov bin/test_cert.c 279c51ce338SDmitri Tikhonov) 2808ca33e0eSDmitri TikhonovLIST(APPEND LIBS pthread m) 28150aadb33SDmitri Tikhonov 2825d77f141SAmol Deshpande#MSVC 283461e84d8SAmol DeshpandeELSE() 2845392f7a3SLiteSpeed Tech 285461e84d8SAmol Deshpandeadd_executable(http_client 2869a690580SDmitri Tikhonov bin/http_client.c 2879a690580SDmitri Tikhonov bin/prog.c 2889a690580SDmitri Tikhonov bin/test_common.c 289fb3e20e0SDmitri Tikhonov bin/test_cert.c 290461e84d8SAmol Deshpande wincompat/getopt.c 291461e84d8SAmol Deshpande wincompat/getopt1.c 292461e84d8SAmol Deshpande) 2938ca33e0eSDmitri TikhonovLIST(APPEND LIBS ws2_32) 294461e84d8SAmol Deshpande 295461e84d8SAmol DeshpandeENDIF() 296461e84d8SAmol Deshpande 2978ca33e0eSDmitri TikhonovTARGET_LINK_LIBRARIES(http_client ${LIBS}) 2985392f7a3SLiteSpeed TechTARGET_LINK_LIBRARIES(http_server ${LIBS}) 299fb3e20e0SDmitri TikhonovIF(NOT MSVC) 3000adf085aSDmitri TikhonovTARGET_LINK_LIBRARIES(md5_server ${LIBS}) 3010adf085aSDmitri TikhonovTARGET_LINK_LIBRARIES(md5_client ${LIBS}) 302fb3e20e0SDmitri TikhonovENDIF() 3030adf085aSDmitri TikhonovTARGET_LINK_LIBRARIES(echo_server ${LIBS}) 3040adf085aSDmitri TikhonovTARGET_LINK_LIBRARIES(echo_client ${LIBS}) 305b1a7c3f9SDmitri TikhonovTARGET_LINK_LIBRARIES(duck_server ${LIBS}) 306b1a7c3f9SDmitri TikhonovTARGET_LINK_LIBRARIES(duck_client ${LIBS}) 30750aadb33SDmitri Tikhonov 3089a690580SDmitri Tikhonovadd_subdirectory(bin) 3099a690580SDmitri TikhonovENDIF() # LSQUIC_BIN 31050aadb33SDmitri Tikhonov 31121c6983aSRahul Jadhavadd_subdirectory(src) 31221c6983aSRahul Jadhav 3139a690580SDmitri TikhonovIF(LSQUIC_TESTS AND CMAKE_BUILD_TYPE STREQUAL "Debug") 3147fbe101bSDmitri Tikhonov # Our test framework relies on assertions, only compile if assertions are 3157fbe101bSDmitri Tikhonov # enabled. 3167fbe101bSDmitri Tikhonov # 3177fbe101bSDmitri Tikhonov enable_testing() 3189a690580SDmitri Tikhonov add_subdirectory(tests) 3197fbe101bSDmitri TikhonovENDIF() 3207fbe101bSDmitri Tikhonov 321feca77f5SDmitri Tikhonov 3220bd32030SDmitri TikhonovFIND_PROGRAM(SPHINX NAMES sphinx-build) 3230bd32030SDmitri TikhonovIF(SPHINX) 3240bd32030SDmitri Tikhonov ADD_CUSTOM_TARGET(docs 3250bd32030SDmitri Tikhonov ${SPHINX} -b html 3260bd32030SDmitri Tikhonov docs 3270bd32030SDmitri Tikhonov docs/_build 3280bd32030SDmitri Tikhonov ) 3290bd32030SDmitri TikhonovELSE() 3300bd32030SDmitri Tikhonov MESSAGE(STATUS "sphinx-build not found: docs won't be made") 3310bd32030SDmitri TikhonovENDIF() 332