CMakeLists.txt revision 06b2a236
106b2a236SDmitri Tikhonov# Copyright (c) 2017 - 2021 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) 11657fe5a13SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4305") # truncation from double to float 117461e84d8SAmol 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") 1181e75f938SDmitri TikhonovIF(CMAKE_BUILD_TYPE STREQUAL "Debug") 119b5d685fcSBob Perper SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Od") 120461e84d8SAmol Deshpande #SET (MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DFIU_ENABLE=1") 121ccd74161SDmitri Tikhonov #SET(LIBS ${LIBS} fiu) 122461e84d8SAmol DeshpandeELSE() 123b5d685fcSBob Perper SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Ox") 124461e84d8SAmol Deshpande # Comment out the following line to compile out debug messages: 125461e84d8SAmol Deshpande #SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_LOWEST_LOG_LEVEL=LSQ_LOG_INFO") 126461e84d8SAmol DeshpandeENDIF() 127461e84d8SAmol Deshpande 128461e84d8SAmol DeshpandeENDIF() #MSVC 129461e84d8SAmol Deshpande 13050aadb33SDmitri Tikhonovset(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_CMAKE_FLAGS} $ENV{EXTRA_CFLAGS}") 13150aadb33SDmitri Tikhonov 13250aadb33SDmitri TikhonovMESSAGE(STATUS "Compiler flags: ${CMAKE_C_FLAGS}") 13350aadb33SDmitri Tikhonov 134fb3e20e0SDmitri Tikhonovfind_package(Perl) 135fb3e20e0SDmitri TikhonovIF(NOT PERL_FOUND) 136fb3e20e0SDmitri Tikhonov MESSAGE(FATAL_ERROR "Perl not found -- need it to generate source code") 137fb3e20e0SDmitri TikhonovENDIF() 138fb3e20e0SDmitri Tikhonov 1392e1429b4SDmitri TikhonovIF(LSQUIC_SHARED_LIB) 1402e1429b4SDmitri Tikhonov SET(LIB_SUFFIX .so) 1412e1429b4SDmitri TikhonovELSE() 1422e1429b4SDmitri Tikhonov SET(LIB_SUFFIX .a) 1432e1429b4SDmitri TikhonovENDIF() 1442e1429b4SDmitri Tikhonov 1458ca33e0eSDmitri TikhonovIF (NOT DEFINED BORINGSSL_INCLUDE AND DEFINED BORINGSSL_DIR) 1468ca33e0eSDmitri Tikhonov FIND_PATH(BORINGSSL_INCLUDE NAMES openssl/ssl.h 1478ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_DIR}/include 1488ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1498ca33e0eSDmitri TikhonovENDIF() 150b1af35d6SDmitri Tikhonov# This must be done before adding other include directories to take 151b1af35d6SDmitri Tikhonov# precedence over header files from other SSL installs. 1528ca33e0eSDmitri Tikhonov 1538ca33e0eSDmitri TikhonovIF (BORINGSSL_INCLUDE) 1548ca33e0eSDmitri Tikhonov MESSAGE(STATUS "BoringSSL include directory ${BORINGSSL_INCLUDE}") 1558ca33e0eSDmitri Tikhonov INCLUDE_DIRECTORIES(${BORINGSSL_INCLUDE}) 156b1af35d6SDmitri TikhonovELSE() 157b1af35d6SDmitri Tikhonov MESSAGE(FATAL_ERROR "BoringSSL headers not found") 158e0197994SDmitri TikhonovENDIF() 15950aadb33SDmitri Tikhonov 1608ca33e0eSDmitri TikhonovIF (NOT DEFINED BORINGSSL_LIB AND DEFINED BORINGSSL_DIR) 1618ca33e0eSDmitri Tikhonov FOREACH(LIB_NAME ssl crypto decrepit) 1628ca33e0eSDmitri Tikhonov IF (CMAKE_SYSTEM_NAME STREQUAL Windows) 1638ca33e0eSDmitri Tikhonov FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 1648ca33e0eSDmitri Tikhonov NAMES ${LIB_NAME} 1658ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_DIR}/${LIB_NAME} 166fb3e20e0SDmitri Tikhonov PATH_SUFFIXES Debug Release MinSizeRel RelWithDebInfo 1678ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1688ca33e0eSDmitri Tikhonov ELSE() 1698ca33e0eSDmitri Tikhonov FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 1702e1429b4SDmitri Tikhonov NAMES lib${LIB_NAME}${LIB_SUFFIX} 1718ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_DIR}/${LIB_NAME} 1728ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1738ca33e0eSDmitri Tikhonov ENDIF() 1748ca33e0eSDmitri Tikhonov IF(BORINGSSL_LIB_${LIB_NAME}) 1758ca33e0eSDmitri Tikhonov MESSAGE(STATUS "Found ${LIB_NAME} library: ${BORINGSSL_LIB_${LIB_NAME}}") 1768ca33e0eSDmitri Tikhonov ELSE() 1778ca33e0eSDmitri Tikhonov MESSAGE(STATUS "${LIB_NAME} library not found") 1788ca33e0eSDmitri Tikhonov ENDIF() 1798ca33e0eSDmitri Tikhonov ENDFOREACH() 1808ca33e0eSDmitri Tikhonov 1818ca33e0eSDmitri TikhonovELSE() 1828ca33e0eSDmitri Tikhonov 1838ca33e0eSDmitri Tikhonov 1848ca33e0eSDmitri Tikhonov FOREACH(LIB_NAME ssl crypto decrepit) 1858ca33e0eSDmitri Tikhonov IF (CMAKE_SYSTEM_NAME STREQUAL Windows) 1868ca33e0eSDmitri Tikhonov FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 1878ca33e0eSDmitri Tikhonov NAMES ${LIB_NAME} 1888ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_LIB} 1898ca33e0eSDmitri Tikhonov PATH_SUFFIXES Debug Release MinSizeRel RelWithDebInfo 1908ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1918ca33e0eSDmitri Tikhonov ELSE() 1928ca33e0eSDmitri Tikhonov FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 1932e1429b4SDmitri Tikhonov NAMES lib${LIB_NAME}${LIB_SUFFIX} 1948ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_LIB} 19581558c3fSRahul Jadhav PATH_SUFFIXES ${LIB_NAME} 1968ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1978ca33e0eSDmitri Tikhonov ENDIF() 1988ca33e0eSDmitri Tikhonov IF(BORINGSSL_LIB_${LIB_NAME}) 1998ca33e0eSDmitri Tikhonov MESSAGE(STATUS "Found ${BORINGSSL_LIB} library: ${BORINGSSL_LIB_${LIB_NAME}}") 2008ca33e0eSDmitri Tikhonov ELSE() 2018ca33e0eSDmitri Tikhonov MESSAGE(STATUS "${BORINGSSL_LIB} library not found") 2028ca33e0eSDmitri Tikhonov ENDIF() 2038ca33e0eSDmitri Tikhonov ENDFOREACH() 204461e84d8SAmol Deshpande 2058ca33e0eSDmitri TikhonovENDIF() 2068ca33e0eSDmitri Tikhonov 2078ca33e0eSDmitri TikhonovSET(CMAKE_INCLUDE_CURRENT_DIR ON) 20883506617SDmitri TikhonovINCLUDE_DIRECTORIES(include) 209b1af35d6SDmitri TikhonovIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin") 21050aadb33SDmitri Tikhonov # Find libevent on FreeBSD: 2118ca33e0eSDmitri Tikhonov include_directories( /usr/local/include ) 2128ca33e0eSDmitri Tikhonov link_directories( /usr/local/lib ) 213b1af35d6SDmitri TikhonovENDIF() 214b1af35d6SDmitri Tikhonov 215b1af35d6SDmitri Tikhonov# Find zlib and libevent header files and library files 216b1af35d6SDmitri Tikhonov# TODO: libevent is not strictly necessary to build the library. 217b1af35d6SDmitri TikhonovFIND_PATH(ZLIB_INCLUDE_DIR NAMES zlib.h) 218b1af35d6SDmitri TikhonovIF (ZLIB_INCLUDE_DIR) 219b1af35d6SDmitri Tikhonov INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) 220b1af35d6SDmitri TikhonovELSE() 221b1af35d6SDmitri Tikhonov MESSAGE(FATAL_ERROR "zlib.h was not found") 222b1af35d6SDmitri TikhonovENDIF() 223b1af35d6SDmitri TikhonovIF (CMAKE_SYSTEM_NAME STREQUAL Windows) 224b1af35d6SDmitri Tikhonov FIND_LIBRARY(ZLIB_LIB zlib) 225b1af35d6SDmitri TikhonovELSEIF(CMAKE_SYSTEM_NAME STREQUAL Darwin) 226b1af35d6SDmitri Tikhonov # XXX somehow FIND_LIBRARY() does not find zlib on Travis? 227b1af35d6SDmitri Tikhonov SET(ZLIB_LIB z) 228b1af35d6SDmitri TikhonovELSE() 2292e1429b4SDmitri Tikhonov FIND_LIBRARY(ZLIB_LIB libz${LIB_SUFFIX}) 230b1af35d6SDmitri TikhonovENDIF() 231b1af35d6SDmitri TikhonovIF(ZLIB_LIB) 232b1af35d6SDmitri Tikhonov MESSAGE(STATUS "Found zlib: ${ZLIB_LIB}") 233b1af35d6SDmitri TikhonovELSE() 234b1af35d6SDmitri Tikhonov MESSAGE(STATUS "zlib not found") 235b1af35d6SDmitri TikhonovENDIF() 2369a690580SDmitri Tikhonov 237fb3e20e0SDmitri TikhonovIF (LSQUIC_BIN OR LSQUIC_TESTS) 238b1af35d6SDmitri TikhonovFIND_PATH(EVENT_INCLUDE_DIR NAMES event2/event.h) 239b1af35d6SDmitri TikhonovIF (EVENT_INCLUDE_DIR) 240b1af35d6SDmitri Tikhonov INCLUDE_DIRECTORIES(${EVENT_INCLUDE_DIR}) 241b1af35d6SDmitri TikhonovELSE() 242b1af35d6SDmitri Tikhonov MESSAGE(FATAL_ERROR "event2/event.h was not found") 243b1af35d6SDmitri TikhonovENDIF() 244b1af35d6SDmitri TikhonovIF (CMAKE_SYSTEM_NAME STREQUAL Windows) 245b1af35d6SDmitri Tikhonov FIND_LIBRARY(EVENT_LIB event) 246b1af35d6SDmitri TikhonovELSE() 2472e1429b4SDmitri Tikhonov FIND_LIBRARY(EVENT_LIB libevent${LIB_SUFFIX}) 248747be414SDmitri Tikhonov IF(NOT EVENT_LIB) 249747be414SDmitri Tikhonov FIND_LIBRARY(EVENT_LIB libevent.so) 250747be414SDmitri Tikhonov ENDIF() 251b1af35d6SDmitri TikhonovENDIF() 252b1af35d6SDmitri TikhonovIF(EVENT_LIB) 253b1af35d6SDmitri Tikhonov MESSAGE(STATUS "Found event: ${EVENT_LIB}") 254b1af35d6SDmitri TikhonovELSE() 255b1af35d6SDmitri Tikhonov MESSAGE(STATUS "libevent not found") 25650aadb33SDmitri TikhonovENDIF() 257fb3e20e0SDmitri TikhonovSET(LIBS lsquic ${EVENT_LIB} ${BORINGSSL_LIB_ssl} ${BORINGSSL_LIB_crypto} ${ZLIB_LIB} ${LIBS}) 258fb3e20e0SDmitri TikhonovIF(MSVC) 259fb3e20e0SDmitri TikhonovFIND_LIBRARY(PCRE_LIB pcre) 260fb3e20e0SDmitri TikhonovIF(PCRE_LIB) 261fb3e20e0SDmitri Tikhonov MESSAGE(STATUS "Found pcre: ${PCRE_LIB}") 262fb3e20e0SDmitri Tikhonov LIST(APPEND LIBS ${PCRE_LIB}) 263fb3e20e0SDmitri TikhonovELSE() 264fb3e20e0SDmitri Tikhonov MESSAGE(STATUS "pcre not found: http_server won't work") 265fb3e20e0SDmitri TikhonovENDIF() 266fb3e20e0SDmitri TikhonovFIND_LIBRARY(PCREPOSIX_LIB pcreposix) 267fb3e20e0SDmitri TikhonovIF(PCREPOSIX_LIB) 268fb3e20e0SDmitri Tikhonov MESSAGE(STATUS "Found pcreposix: ${PCREPOSIX_LIB}") 269fb3e20e0SDmitri Tikhonov LIST(APPEND LIBS ${PCREPOSIX_LIB}) 270fb3e20e0SDmitri TikhonovELSE() 271fb3e20e0SDmitri Tikhonov MESSAGE(STATUS "pcreposix not found: http_server won't work") 272fb3e20e0SDmitri TikhonovENDIF() 273fb3e20e0SDmitri TikhonovLIST(APPEND LIBS ws2_32) 27471eb4000SDmitri TikhonovLIST(APPEND LIBS iphlpapi) 275fb3e20e0SDmitri TikhonovENDIF() 276fb3e20e0SDmitri TikhonovENDIF() # LSQUIC_BIN OR LSQUIC_TESTS 27750aadb33SDmitri Tikhonov 278fb3e20e0SDmitri TikhonovIF(LSQUIC_BIN) 279fb3e20e0SDmitri TikhonovIF(MSVC) 280fb3e20e0SDmitri Tikhonov SET(GETOPT_C wincompat/getopt.c) 281fb3e20e0SDmitri TikhonovENDIF() 282fb3e20e0SDmitri Tikhonovadd_executable(http_server bin/http_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 283fb3e20e0SDmitri TikhonovIF(NOT MSVC) # TODO: port MD5 server and client to Windows 284fb3e20e0SDmitri Tikhonovadd_executable(md5_server bin/md5_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 285fb3e20e0SDmitri Tikhonovadd_executable(md5_client bin/md5_client.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 286fb3e20e0SDmitri TikhonovENDIF() 287fb3e20e0SDmitri Tikhonovadd_executable(echo_server bin/echo_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 288fb3e20e0SDmitri Tikhonovadd_executable(echo_client bin/echo_client.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 289b1a7c3f9SDmitri Tikhonovadd_executable(duck_server bin/duck_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 290b1a7c3f9SDmitri Tikhonovadd_executable(duck_client bin/duck_client.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 2918ca33e0eSDmitri Tikhonov 292b93f59beSBob Perper 29346a5b669SDmitri TikhonovIF (NOT MSVC) 2945392f7a3SLiteSpeed Tech 295c51ce338SDmitri Tikhonovadd_executable(http_client 2969a690580SDmitri Tikhonov bin/http_client.c 2979a690580SDmitri Tikhonov bin/prog.c 2989a690580SDmitri Tikhonov bin/test_common.c 2999a690580SDmitri Tikhonov bin/test_cert.c 300c51ce338SDmitri Tikhonov) 3018ca33e0eSDmitri TikhonovLIST(APPEND LIBS pthread m) 30250aadb33SDmitri Tikhonov 3035d77f141SAmol Deshpande#MSVC 304461e84d8SAmol DeshpandeELSE() 3055392f7a3SLiteSpeed Tech 306461e84d8SAmol Deshpandeadd_executable(http_client 3079a690580SDmitri Tikhonov bin/http_client.c 3089a690580SDmitri Tikhonov bin/prog.c 3099a690580SDmitri Tikhonov bin/test_common.c 310fb3e20e0SDmitri Tikhonov bin/test_cert.c 311461e84d8SAmol Deshpande wincompat/getopt.c 312461e84d8SAmol Deshpande wincompat/getopt1.c 313461e84d8SAmol Deshpande) 3148ca33e0eSDmitri TikhonovLIST(APPEND LIBS ws2_32) 315461e84d8SAmol Deshpande 316461e84d8SAmol DeshpandeENDIF() 317461e84d8SAmol Deshpande 3188ca33e0eSDmitri TikhonovTARGET_LINK_LIBRARIES(http_client ${LIBS}) 3195392f7a3SLiteSpeed TechTARGET_LINK_LIBRARIES(http_server ${LIBS}) 320fb3e20e0SDmitri TikhonovIF(NOT MSVC) 3210adf085aSDmitri TikhonovTARGET_LINK_LIBRARIES(md5_server ${LIBS}) 3220adf085aSDmitri TikhonovTARGET_LINK_LIBRARIES(md5_client ${LIBS}) 323fb3e20e0SDmitri TikhonovENDIF() 3240adf085aSDmitri TikhonovTARGET_LINK_LIBRARIES(echo_server ${LIBS}) 3250adf085aSDmitri TikhonovTARGET_LINK_LIBRARIES(echo_client ${LIBS}) 326b1a7c3f9SDmitri TikhonovTARGET_LINK_LIBRARIES(duck_server ${LIBS}) 327b1a7c3f9SDmitri TikhonovTARGET_LINK_LIBRARIES(duck_client ${LIBS}) 32850aadb33SDmitri Tikhonov 3299a690580SDmitri Tikhonovadd_subdirectory(bin) 3309a690580SDmitri TikhonovENDIF() # LSQUIC_BIN 33150aadb33SDmitri Tikhonov 33221c6983aSRahul Jadhavadd_subdirectory(src) 33321c6983aSRahul Jadhav 3349a690580SDmitri TikhonovIF(LSQUIC_TESTS AND CMAKE_BUILD_TYPE STREQUAL "Debug") 3357fbe101bSDmitri Tikhonov # Our test framework relies on assertions, only compile if assertions are 3367fbe101bSDmitri Tikhonov # enabled. 3377fbe101bSDmitri Tikhonov # 3387fbe101bSDmitri Tikhonov enable_testing() 3399a690580SDmitri Tikhonov add_subdirectory(tests) 3407fbe101bSDmitri TikhonovENDIF() 3417fbe101bSDmitri Tikhonov 342feca77f5SDmitri Tikhonov 3430bd32030SDmitri TikhonovFIND_PROGRAM(SPHINX NAMES sphinx-build) 3440bd32030SDmitri TikhonovIF(SPHINX) 3450bd32030SDmitri Tikhonov ADD_CUSTOM_TARGET(docs 3460bd32030SDmitri Tikhonov ${SPHINX} -b html 3470bd32030SDmitri Tikhonov docs 3480bd32030SDmitri Tikhonov docs/_build 3490bd32030SDmitri Tikhonov ) 3500bd32030SDmitri TikhonovELSE() 3510bd32030SDmitri Tikhonov MESSAGE(STATUS "sphinx-build not found: docs won't be made") 3520bd32030SDmitri TikhonovENDIF() 353966c52fcSJonas Vautherin 354966c52fcSJonas VautherinINSTALL(FILES 355966c52fcSJonas Vautherin include/lsquic.h 356966c52fcSJonas Vautherin include/lsquic_types.h 357966c52fcSJonas Vautherin include/lsxpack_header.h 358966c52fcSJonas Vautherin DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lsquic 359966c52fcSJonas Vautherin) 360