CMakeLists.txt revision c0b26eab
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) 102e1429b4SDmitri TikhonovOPTION(LSQUIC_SHARED_LIB "Compile as shared librarry" OFF) 1100c58df3SDmitri TikhonovOPTION(LSQUIC_DEVEL "Compile in development mode" OFF) 129a690580SDmitri Tikhonov 13966c52fcSJonas VautherinINCLUDE(GNUInstallDirs) 14966c52fcSJonas Vautherin 1512693a01SDmitri TikhonovIF (CMAKE_SYSTEM_NAME STREQUAL "Linux") 1612693a01SDmitri Tikhonov # If using older glibc, need to link with -lrt. See clock_getres(2). 1712693a01SDmitri Tikhonov EXECUTE_PROCESS( 1812693a01SDmitri Tikhonov COMMAND ${PROJECT_SOURCE_DIR}/print-glibc-version.sh ${CMAKE_C_COMPILER} 1912693a01SDmitri Tikhonov OUTPUT_VARIABLE GLIBC_VERSION) 2012693a01SDmitri Tikhonov IF(NOT GLIBC_VERSION EQUAL "" AND GLIBC_VERSION VERSION_LESS 2.17) 2112693a01SDmitri Tikhonov SET(LIBS ${LIBS} rt) 2212693a01SDmitri Tikhonov ENDIF() 2321c6983aSRahul JadhavELSEIF (CMAKE_SYSTEM_NAME STREQUAL "Android") 2421c6983aSRahul Jadhav # for android-ndk >= r19b 2521c6983aSRahul Jadhav set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY "BOTH") 2621c6983aSRahul Jadhav set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE "BOTH") 2721c6983aSRahul Jadhav set(CMAKE_FIND_ROOT_PATH_MODE_PATH "BOTH") 28ccd74161SDmitri TikhonovENDIF() 29ccd74161SDmitri Tikhonov 301e75f938SDmitri TikhonovIF("${CMAKE_BUILD_TYPE}" STREQUAL "") 311e75f938SDmitri Tikhonov SET(CMAKE_BUILD_TYPE Debug) 3250aadb33SDmitri TikhonovENDIF() 3350aadb33SDmitri Tikhonov 341e75f938SDmitri TikhonovMESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}") 3550aadb33SDmitri Tikhonov 36a0e1aeeeSDmitri TikhonovIF (NOT "$ENV{EXTRA_CFLAGS}" MATCHES "-DLSQUIC_DEBUG_NEXT_ADV_TICK") 37a0e1aeeeSDmitri Tikhonov SET(MY_CMAKE_FLAGS "-DLSQUIC_DEBUG_NEXT_ADV_TICK=1") 38a0e1aeeeSDmitri TikhonovENDIF() 39b93f59beSBob Perper 40c0b26eabSDmitri TikhonovIF (NOT "$ENV{EXTRA_CFLAGS}" MATCHES "-DLSQUIC_CONN_STATS=") 41c0b26eabSDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_CONN_STATS=1") 42c0b26eabSDmitri TikhonovENDIF() 43c0b26eabSDmitri Tikhonov 4446a5b669SDmitri TikhonovIF (NOT MSVC) 45461e84d8SAmol Deshpande 4650aadb33SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wall -Wextra -Wno-unused-parameter") 4750aadb33SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -fno-omit-frame-pointer") 485392f7a3SLiteSpeed TechINCLUDE(CheckCCompilerFlag) 495392f7a3SLiteSpeed TechCHECK_C_COMPILER_FLAG(-Wno-implicit-fallthrough HAS_NO_IMPLICIT_FALLTHROUGH) 505392f7a3SLiteSpeed TechIF (HAS_NO_IMPLICIT_FALLTHROUGH) 515392f7a3SLiteSpeed Tech SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wno-implicit-fallthrough") 525392f7a3SLiteSpeed TechENDIF() 5350aadb33SDmitri Tikhonov 54e0197994SDmitri TikhonovIF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.3) 5550aadb33SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wno-missing-field-initializers") 5650aadb33SDmitri TikhonovENDIF() 575392f7a3SLiteSpeed Tech 58662de5e1SDmitri TikhonovIF(LSQUIC_FIU) 59662de5e1SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DFIU_ENABLE=1") 60662de5e1SDmitri Tikhonov SET(LIBS ${LIBS} fiu) 61662de5e1SDmitri TikhonovENDIF() 62662de5e1SDmitri Tikhonov 631e75f938SDmitri TikhonovIF(CMAKE_BUILD_TYPE STREQUAL "Debug") 6450aadb33SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -O0 -g3") 65db8ac9eeSDmitri Tikhonov IF(CMAKE_C_COMPILER MATCHES "clang" AND 6603e6b668SDmitri Tikhonov NOT "$ENV{TRAVIS}" MATCHES "^true$" AND 6703e6b668SDmitri Tikhonov NOT "$ENV{EXTRA_CFLAGS}" MATCHES "-fsanitize") 6850aadb33SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -fsanitize=address") 69d6937ddcSinitlife SET(LIBS ${LIBS} -fsanitize=address) 7050aadb33SDmitri Tikhonov ENDIF() 715392f7a3SLiteSpeed Tech # Uncomment to enable cleartext protocol mode (no crypto): 725392f7a3SLiteSpeed Tech #SET (MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_ENABLE_HANDSHAKE_DISABLE=1") 7350aadb33SDmitri TikhonovELSE() 7450aadb33SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -O3 -g0") 7550aadb33SDmitri Tikhonov # Comment out the following line to compile out debug messages: 7650aadb33SDmitri Tikhonov #SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_LOWEST_LOG_LEVEL=LSQ_LOG_INFO") 7750aadb33SDmitri TikhonovENDIF() 7850aadb33SDmitri Tikhonov 7900c58df3SDmitri TikhonovIF (LSQUIC_DEVEL) 8000c58df3SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_DEVEL=1") 8100c58df3SDmitri TikhonovENDIF() 8200c58df3SDmitri Tikhonov 8367b0dc15SDmitri TikhonovIF(LSQUIC_PROFILE EQUAL 1) 8467b0dc15SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -g -pg") 8567b0dc15SDmitri TikhonovENDIF() 8667b0dc15SDmitri Tikhonov 8716a9b66aSDmitri TikhonovIF(LSQUIC_COVERAGE EQUAL 1) 8816a9b66aSDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -fprofile-arcs -ftest-coverage") 8916a9b66aSDmitri TikhonovENDIF() 9016a9b66aSDmitri Tikhonov 9150aadb33SDmitri TikhonovIF(MY_CMAKE_FLAGS MATCHES "fsanitize=address") 9250aadb33SDmitri Tikhonov MESSAGE(STATUS "AddressSanitizer is ON") 9350aadb33SDmitri TikhonovELSE() 9450aadb33SDmitri Tikhonov MESSAGE(STATUS "AddressSanitizer is OFF") 9550aadb33SDmitri TikhonovENDIF() 9650aadb33SDmitri Tikhonov 97461e84d8SAmol Deshpande#MSVC 98461e84d8SAmol DeshpandeELSE() 99fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4100") # unreferenced formal parameter 100fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4115") # unnamed type definition in parentheses 101fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4116") # named type definition in parentheses 102fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4146") # unary minus operator applied to unsigned type, result still unsigned 103fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4132") # const initialization 104fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4200") # zero-sized array 105fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4204") # non-constant aggregate initializer 106fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4244") # integer conversion 107fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4245") # conversion from 'int' to 'unsigned int', signed/unsigned mismatch 108fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4267") # integer conversion 1092d296031SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4214") # nonstandard extension used: bit field types other than int 110fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4295") # array is too small to include a terminating null character 111fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4334") # result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) 112fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4456") # hide previous local declaration 113fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4459") # hide global declaration 114fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4706") # assignment within conditional expression 115464a1af9SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4090") # different 'const' qualifier (TODO: debug ls-sfparser.c) 116461e84d8SAmol 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") 1171e75f938SDmitri TikhonovIF(CMAKE_BUILD_TYPE STREQUAL "Debug") 118b5d685fcSBob Perper SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Od") 119461e84d8SAmol Deshpande #SET (MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DFIU_ENABLE=1") 120ccd74161SDmitri Tikhonov #SET(LIBS ${LIBS} fiu) 121461e84d8SAmol DeshpandeELSE() 122b5d685fcSBob Perper SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Ox") 123461e84d8SAmol Deshpande # Comment out the following line to compile out debug messages: 124461e84d8SAmol Deshpande #SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_LOWEST_LOG_LEVEL=LSQ_LOG_INFO") 125461e84d8SAmol DeshpandeENDIF() 126461e84d8SAmol Deshpande 127461e84d8SAmol DeshpandeENDIF() #MSVC 128461e84d8SAmol Deshpande 12950aadb33SDmitri Tikhonovset(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_CMAKE_FLAGS} $ENV{EXTRA_CFLAGS}") 13050aadb33SDmitri Tikhonov 13150aadb33SDmitri TikhonovMESSAGE(STATUS "Compiler flags: ${CMAKE_C_FLAGS}") 13250aadb33SDmitri Tikhonov 133fb3e20e0SDmitri Tikhonovfind_package(Perl) 134fb3e20e0SDmitri TikhonovIF(NOT PERL_FOUND) 135fb3e20e0SDmitri Tikhonov MESSAGE(FATAL_ERROR "Perl not found -- need it to generate source code") 136fb3e20e0SDmitri TikhonovENDIF() 137fb3e20e0SDmitri Tikhonov 1382e1429b4SDmitri TikhonovIF(LSQUIC_SHARED_LIB) 1392e1429b4SDmitri Tikhonov SET(LIB_SUFFIX .so) 1402e1429b4SDmitri TikhonovELSE() 1412e1429b4SDmitri Tikhonov SET(LIB_SUFFIX .a) 1422e1429b4SDmitri TikhonovENDIF() 1432e1429b4SDmitri Tikhonov 1448ca33e0eSDmitri TikhonovIF (NOT DEFINED BORINGSSL_INCLUDE AND DEFINED BORINGSSL_DIR) 1458ca33e0eSDmitri Tikhonov FIND_PATH(BORINGSSL_INCLUDE NAMES openssl/ssl.h 1468ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_DIR}/include 1478ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1488ca33e0eSDmitri TikhonovENDIF() 149b1af35d6SDmitri Tikhonov# This must be done before adding other include directories to take 150b1af35d6SDmitri Tikhonov# precedence over header files from other SSL installs. 1518ca33e0eSDmitri Tikhonov 1528ca33e0eSDmitri TikhonovIF (BORINGSSL_INCLUDE) 1538ca33e0eSDmitri Tikhonov MESSAGE(STATUS "BoringSSL include directory ${BORINGSSL_INCLUDE}") 1548ca33e0eSDmitri Tikhonov INCLUDE_DIRECTORIES(${BORINGSSL_INCLUDE}) 155b1af35d6SDmitri TikhonovELSE() 156b1af35d6SDmitri Tikhonov MESSAGE(FATAL_ERROR "BoringSSL headers not found") 157e0197994SDmitri TikhonovENDIF() 15850aadb33SDmitri Tikhonov 1598ca33e0eSDmitri TikhonovIF (NOT DEFINED BORINGSSL_LIB AND DEFINED BORINGSSL_DIR) 1608ca33e0eSDmitri Tikhonov FOREACH(LIB_NAME ssl crypto decrepit) 1618ca33e0eSDmitri Tikhonov IF (CMAKE_SYSTEM_NAME STREQUAL Windows) 1628ca33e0eSDmitri Tikhonov FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 1638ca33e0eSDmitri Tikhonov NAMES ${LIB_NAME} 1648ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_DIR}/${LIB_NAME} 165fb3e20e0SDmitri Tikhonov PATH_SUFFIXES Debug Release MinSizeRel RelWithDebInfo 1668ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1678ca33e0eSDmitri Tikhonov ELSE() 1688ca33e0eSDmitri Tikhonov FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 1692e1429b4SDmitri Tikhonov NAMES lib${LIB_NAME}${LIB_SUFFIX} 1708ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_DIR}/${LIB_NAME} 1718ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1728ca33e0eSDmitri Tikhonov ENDIF() 1738ca33e0eSDmitri Tikhonov IF(BORINGSSL_LIB_${LIB_NAME}) 1748ca33e0eSDmitri Tikhonov MESSAGE(STATUS "Found ${LIB_NAME} library: ${BORINGSSL_LIB_${LIB_NAME}}") 1758ca33e0eSDmitri Tikhonov ELSE() 1768ca33e0eSDmitri Tikhonov MESSAGE(STATUS "${LIB_NAME} library not found") 1778ca33e0eSDmitri Tikhonov ENDIF() 1788ca33e0eSDmitri Tikhonov ENDFOREACH() 1798ca33e0eSDmitri Tikhonov 1808ca33e0eSDmitri TikhonovELSE() 1818ca33e0eSDmitri Tikhonov 1828ca33e0eSDmitri Tikhonov 1838ca33e0eSDmitri Tikhonov FOREACH(LIB_NAME ssl crypto decrepit) 1848ca33e0eSDmitri Tikhonov IF (CMAKE_SYSTEM_NAME STREQUAL Windows) 1858ca33e0eSDmitri Tikhonov FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 1868ca33e0eSDmitri Tikhonov NAMES ${LIB_NAME} 1878ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_LIB} 1888ca33e0eSDmitri Tikhonov PATH_SUFFIXES Debug Release MinSizeRel RelWithDebInfo 1898ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1908ca33e0eSDmitri Tikhonov ELSE() 1918ca33e0eSDmitri Tikhonov FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 1922e1429b4SDmitri Tikhonov NAMES lib${LIB_NAME}${LIB_SUFFIX} 1938ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_LIB} 19481558c3fSRahul Jadhav PATH_SUFFIXES ${LIB_NAME} 1958ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1968ca33e0eSDmitri Tikhonov ENDIF() 1978ca33e0eSDmitri Tikhonov IF(BORINGSSL_LIB_${LIB_NAME}) 1988ca33e0eSDmitri Tikhonov MESSAGE(STATUS "Found ${BORINGSSL_LIB} library: ${BORINGSSL_LIB_${LIB_NAME}}") 1998ca33e0eSDmitri Tikhonov ELSE() 2008ca33e0eSDmitri Tikhonov MESSAGE(STATUS "${BORINGSSL_LIB} library not found") 2018ca33e0eSDmitri Tikhonov ENDIF() 2028ca33e0eSDmitri Tikhonov ENDFOREACH() 203461e84d8SAmol Deshpande 2048ca33e0eSDmitri TikhonovENDIF() 2058ca33e0eSDmitri Tikhonov 2068ca33e0eSDmitri TikhonovSET(CMAKE_INCLUDE_CURRENT_DIR ON) 20783506617SDmitri TikhonovINCLUDE_DIRECTORIES(include) 208b1af35d6SDmitri TikhonovIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin") 20950aadb33SDmitri Tikhonov # Find libevent on FreeBSD: 2108ca33e0eSDmitri Tikhonov include_directories( /usr/local/include ) 2118ca33e0eSDmitri Tikhonov link_directories( /usr/local/lib ) 212b1af35d6SDmitri TikhonovENDIF() 213b1af35d6SDmitri Tikhonov 214b1af35d6SDmitri Tikhonov# Find zlib and libevent header files and library files 215b1af35d6SDmitri Tikhonov# TODO: libevent is not strictly necessary to build the library. 216b1af35d6SDmitri TikhonovFIND_PATH(ZLIB_INCLUDE_DIR NAMES zlib.h) 217b1af35d6SDmitri TikhonovIF (ZLIB_INCLUDE_DIR) 218b1af35d6SDmitri Tikhonov INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) 219b1af35d6SDmitri TikhonovELSE() 220b1af35d6SDmitri Tikhonov MESSAGE(FATAL_ERROR "zlib.h was not found") 221b1af35d6SDmitri TikhonovENDIF() 222b1af35d6SDmitri TikhonovIF (CMAKE_SYSTEM_NAME STREQUAL Windows) 223b1af35d6SDmitri Tikhonov FIND_LIBRARY(ZLIB_LIB zlib) 224b1af35d6SDmitri TikhonovELSEIF(CMAKE_SYSTEM_NAME STREQUAL Darwin) 225b1af35d6SDmitri Tikhonov # XXX somehow FIND_LIBRARY() does not find zlib on Travis? 226b1af35d6SDmitri Tikhonov SET(ZLIB_LIB z) 227b1af35d6SDmitri TikhonovELSE() 2282e1429b4SDmitri Tikhonov FIND_LIBRARY(ZLIB_LIB libz${LIB_SUFFIX}) 229b1af35d6SDmitri TikhonovENDIF() 230b1af35d6SDmitri TikhonovIF(ZLIB_LIB) 231b1af35d6SDmitri Tikhonov MESSAGE(STATUS "Found zlib: ${ZLIB_LIB}") 232b1af35d6SDmitri TikhonovELSE() 233b1af35d6SDmitri Tikhonov MESSAGE(STATUS "zlib not found") 234b1af35d6SDmitri TikhonovENDIF() 2359a690580SDmitri Tikhonov 236fb3e20e0SDmitri TikhonovIF (LSQUIC_BIN OR LSQUIC_TESTS) 237b1af35d6SDmitri TikhonovFIND_PATH(EVENT_INCLUDE_DIR NAMES event2/event.h) 238b1af35d6SDmitri TikhonovIF (EVENT_INCLUDE_DIR) 239b1af35d6SDmitri Tikhonov INCLUDE_DIRECTORIES(${EVENT_INCLUDE_DIR}) 240b1af35d6SDmitri TikhonovELSE() 241b1af35d6SDmitri Tikhonov MESSAGE(FATAL_ERROR "event2/event.h was not found") 242b1af35d6SDmitri TikhonovENDIF() 243b1af35d6SDmitri TikhonovIF (CMAKE_SYSTEM_NAME STREQUAL Windows) 244b1af35d6SDmitri Tikhonov FIND_LIBRARY(EVENT_LIB event) 245b1af35d6SDmitri TikhonovELSE() 2462e1429b4SDmitri Tikhonov FIND_LIBRARY(EVENT_LIB libevent${LIB_SUFFIX}) 247747be414SDmitri Tikhonov IF(NOT EVENT_LIB) 248747be414SDmitri Tikhonov FIND_LIBRARY(EVENT_LIB libevent.so) 249747be414SDmitri Tikhonov ENDIF() 250b1af35d6SDmitri TikhonovENDIF() 251b1af35d6SDmitri TikhonovIF(EVENT_LIB) 252b1af35d6SDmitri Tikhonov MESSAGE(STATUS "Found event: ${EVENT_LIB}") 253b1af35d6SDmitri TikhonovELSE() 254b1af35d6SDmitri Tikhonov MESSAGE(STATUS "libevent not found") 25550aadb33SDmitri TikhonovENDIF() 256fb3e20e0SDmitri TikhonovSET(LIBS lsquic ${EVENT_LIB} ${BORINGSSL_LIB_ssl} ${BORINGSSL_LIB_crypto} ${ZLIB_LIB} ${LIBS}) 257fb3e20e0SDmitri TikhonovIF(MSVC) 258fb3e20e0SDmitri TikhonovFIND_LIBRARY(PCRE_LIB pcre) 259fb3e20e0SDmitri TikhonovIF(PCRE_LIB) 260fb3e20e0SDmitri Tikhonov MESSAGE(STATUS "Found pcre: ${PCRE_LIB}") 261fb3e20e0SDmitri Tikhonov LIST(APPEND LIBS ${PCRE_LIB}) 262fb3e20e0SDmitri TikhonovELSE() 263fb3e20e0SDmitri Tikhonov MESSAGE(STATUS "pcre not found: http_server won't work") 264fb3e20e0SDmitri TikhonovENDIF() 265fb3e20e0SDmitri TikhonovFIND_LIBRARY(PCREPOSIX_LIB pcreposix) 266fb3e20e0SDmitri TikhonovIF(PCREPOSIX_LIB) 267fb3e20e0SDmitri Tikhonov MESSAGE(STATUS "Found pcreposix: ${PCREPOSIX_LIB}") 268fb3e20e0SDmitri Tikhonov LIST(APPEND LIBS ${PCREPOSIX_LIB}) 269fb3e20e0SDmitri TikhonovELSE() 270fb3e20e0SDmitri Tikhonov MESSAGE(STATUS "pcreposix not found: http_server won't work") 271fb3e20e0SDmitri TikhonovENDIF() 272fb3e20e0SDmitri TikhonovLIST(APPEND LIBS ws2_32) 273fb3e20e0SDmitri TikhonovENDIF() 274fb3e20e0SDmitri TikhonovENDIF() # LSQUIC_BIN OR LSQUIC_TESTS 27550aadb33SDmitri Tikhonov 276fb3e20e0SDmitri TikhonovIF(LSQUIC_BIN) 277fb3e20e0SDmitri TikhonovIF(MSVC) 278fb3e20e0SDmitri Tikhonov SET(GETOPT_C wincompat/getopt.c) 279fb3e20e0SDmitri TikhonovENDIF() 280fb3e20e0SDmitri Tikhonovadd_executable(http_server bin/http_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 281fb3e20e0SDmitri TikhonovIF(NOT MSVC) # TODO: port MD5 server and client to Windows 282fb3e20e0SDmitri Tikhonovadd_executable(md5_server bin/md5_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 283fb3e20e0SDmitri Tikhonovadd_executable(md5_client bin/md5_client.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 284fb3e20e0SDmitri TikhonovENDIF() 285fb3e20e0SDmitri Tikhonovadd_executable(echo_server bin/echo_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 286fb3e20e0SDmitri Tikhonovadd_executable(echo_client bin/echo_client.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 287b1a7c3f9SDmitri Tikhonovadd_executable(duck_server bin/duck_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 288b1a7c3f9SDmitri Tikhonovadd_executable(duck_client bin/duck_client.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 2898ca33e0eSDmitri Tikhonov 290b93f59beSBob Perper 29146a5b669SDmitri TikhonovIF (NOT MSVC) 2925392f7a3SLiteSpeed Tech 293c51ce338SDmitri Tikhonovadd_executable(http_client 2949a690580SDmitri Tikhonov bin/http_client.c 2959a690580SDmitri Tikhonov bin/prog.c 2969a690580SDmitri Tikhonov bin/test_common.c 2979a690580SDmitri Tikhonov bin/test_cert.c 298c51ce338SDmitri Tikhonov) 2998ca33e0eSDmitri TikhonovLIST(APPEND LIBS pthread m) 30050aadb33SDmitri Tikhonov 3015d77f141SAmol Deshpande#MSVC 302461e84d8SAmol DeshpandeELSE() 3035392f7a3SLiteSpeed Tech 304461e84d8SAmol Deshpandeadd_executable(http_client 3059a690580SDmitri Tikhonov bin/http_client.c 3069a690580SDmitri Tikhonov bin/prog.c 3079a690580SDmitri Tikhonov bin/test_common.c 308fb3e20e0SDmitri Tikhonov bin/test_cert.c 309461e84d8SAmol Deshpande wincompat/getopt.c 310461e84d8SAmol Deshpande wincompat/getopt1.c 311461e84d8SAmol Deshpande) 3128ca33e0eSDmitri TikhonovLIST(APPEND LIBS ws2_32) 313461e84d8SAmol Deshpande 314461e84d8SAmol DeshpandeENDIF() 315461e84d8SAmol Deshpande 3168ca33e0eSDmitri TikhonovTARGET_LINK_LIBRARIES(http_client ${LIBS}) 3175392f7a3SLiteSpeed TechTARGET_LINK_LIBRARIES(http_server ${LIBS}) 318fb3e20e0SDmitri TikhonovIF(NOT MSVC) 3190adf085aSDmitri TikhonovTARGET_LINK_LIBRARIES(md5_server ${LIBS}) 3200adf085aSDmitri TikhonovTARGET_LINK_LIBRARIES(md5_client ${LIBS}) 321fb3e20e0SDmitri TikhonovENDIF() 3220adf085aSDmitri TikhonovTARGET_LINK_LIBRARIES(echo_server ${LIBS}) 3230adf085aSDmitri TikhonovTARGET_LINK_LIBRARIES(echo_client ${LIBS}) 324b1a7c3f9SDmitri TikhonovTARGET_LINK_LIBRARIES(duck_server ${LIBS}) 325b1a7c3f9SDmitri TikhonovTARGET_LINK_LIBRARIES(duck_client ${LIBS}) 32650aadb33SDmitri Tikhonov 3279a690580SDmitri Tikhonovadd_subdirectory(bin) 3289a690580SDmitri TikhonovENDIF() # LSQUIC_BIN 32950aadb33SDmitri Tikhonov 33021c6983aSRahul Jadhavadd_subdirectory(src) 33121c6983aSRahul Jadhav 3329a690580SDmitri TikhonovIF(LSQUIC_TESTS AND CMAKE_BUILD_TYPE STREQUAL "Debug") 3337fbe101bSDmitri Tikhonov # Our test framework relies on assertions, only compile if assertions are 3347fbe101bSDmitri Tikhonov # enabled. 3357fbe101bSDmitri Tikhonov # 3367fbe101bSDmitri Tikhonov enable_testing() 3379a690580SDmitri Tikhonov add_subdirectory(tests) 3387fbe101bSDmitri TikhonovENDIF() 3397fbe101bSDmitri Tikhonov 340feca77f5SDmitri Tikhonov 3410bd32030SDmitri TikhonovFIND_PROGRAM(SPHINX NAMES sphinx-build) 3420bd32030SDmitri TikhonovIF(SPHINX) 3430bd32030SDmitri Tikhonov ADD_CUSTOM_TARGET(docs 3440bd32030SDmitri Tikhonov ${SPHINX} -b html 3450bd32030SDmitri Tikhonov docs 3460bd32030SDmitri Tikhonov docs/_build 3470bd32030SDmitri Tikhonov ) 3480bd32030SDmitri TikhonovELSE() 3490bd32030SDmitri Tikhonov MESSAGE(STATUS "sphinx-build not found: docs won't be made") 3500bd32030SDmitri TikhonovENDIF() 351966c52fcSJonas Vautherin 352966c52fcSJonas VautherinINSTALL(FILES 353966c52fcSJonas Vautherin include/lsquic.h 354966c52fcSJonas Vautherin include/lsquic_types.h 355966c52fcSJonas Vautherin include/lsxpack_header.h 356966c52fcSJonas Vautherin DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lsquic 357966c52fcSJonas Vautherin) 358