CMakeLists.txt revision 966c52fc
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) 119a690580SDmitri Tikhonov 12966c52fcSJonas VautherinINCLUDE(GNUInstallDirs) 13966c52fcSJonas Vautherin 1412693a01SDmitri TikhonovIF (CMAKE_SYSTEM_NAME STREQUAL "Linux") 1512693a01SDmitri Tikhonov # If using older glibc, need to link with -lrt. See clock_getres(2). 1612693a01SDmitri Tikhonov EXECUTE_PROCESS( 1712693a01SDmitri Tikhonov COMMAND ${PROJECT_SOURCE_DIR}/print-glibc-version.sh ${CMAKE_C_COMPILER} 1812693a01SDmitri Tikhonov OUTPUT_VARIABLE GLIBC_VERSION) 1912693a01SDmitri Tikhonov IF(NOT GLIBC_VERSION EQUAL "" AND GLIBC_VERSION VERSION_LESS 2.17) 2012693a01SDmitri Tikhonov SET(LIBS ${LIBS} rt) 2112693a01SDmitri Tikhonov ENDIF() 2221c6983aSRahul JadhavELSEIF (CMAKE_SYSTEM_NAME STREQUAL "Android") 2321c6983aSRahul Jadhav # for android-ndk >= r19b 2421c6983aSRahul Jadhav set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY "BOTH") 2521c6983aSRahul Jadhav set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE "BOTH") 2621c6983aSRahul Jadhav set(CMAKE_FIND_ROOT_PATH_MODE_PATH "BOTH") 27ccd74161SDmitri TikhonovENDIF() 28ccd74161SDmitri Tikhonov 291e75f938SDmitri TikhonovIF("${CMAKE_BUILD_TYPE}" STREQUAL "") 301e75f938SDmitri Tikhonov SET(CMAKE_BUILD_TYPE Debug) 3150aadb33SDmitri TikhonovENDIF() 3250aadb33SDmitri Tikhonov 331e75f938SDmitri TikhonovMESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}") 3450aadb33SDmitri Tikhonov 35a0e1aeeeSDmitri TikhonovIF (NOT "$ENV{EXTRA_CFLAGS}" MATCHES "-DLSQUIC_DEBUG_NEXT_ADV_TICK") 36a0e1aeeeSDmitri Tikhonov SET(MY_CMAKE_FLAGS "-DLSQUIC_DEBUG_NEXT_ADV_TICK=1") 37a0e1aeeeSDmitri TikhonovENDIF() 38b93f59beSBob Perper 3946a5b669SDmitri TikhonovIF (NOT MSVC) 40461e84d8SAmol Deshpande 4150aadb33SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wall -Wextra -Wno-unused-parameter") 4250aadb33SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -fno-omit-frame-pointer") 435392f7a3SLiteSpeed TechINCLUDE(CheckCCompilerFlag) 445392f7a3SLiteSpeed TechCHECK_C_COMPILER_FLAG(-Wno-implicit-fallthrough HAS_NO_IMPLICIT_FALLTHROUGH) 455392f7a3SLiteSpeed TechIF (HAS_NO_IMPLICIT_FALLTHROUGH) 465392f7a3SLiteSpeed Tech SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wno-implicit-fallthrough") 475392f7a3SLiteSpeed TechENDIF() 4850aadb33SDmitri Tikhonov 49e0197994SDmitri TikhonovIF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.3) 5050aadb33SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wno-missing-field-initializers") 5150aadb33SDmitri TikhonovENDIF() 525392f7a3SLiteSpeed Tech 53662de5e1SDmitri TikhonovIF(LSQUIC_FIU) 54662de5e1SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DFIU_ENABLE=1") 55662de5e1SDmitri Tikhonov SET(LIBS ${LIBS} fiu) 56662de5e1SDmitri TikhonovENDIF() 57662de5e1SDmitri Tikhonov 581e75f938SDmitri TikhonovIF(CMAKE_BUILD_TYPE STREQUAL "Debug") 5950aadb33SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -O0 -g3") 60db8ac9eeSDmitri Tikhonov IF(CMAKE_C_COMPILER MATCHES "clang" AND 6103e6b668SDmitri Tikhonov NOT "$ENV{TRAVIS}" MATCHES "^true$" AND 6203e6b668SDmitri Tikhonov NOT "$ENV{EXTRA_CFLAGS}" MATCHES "-fsanitize") 6350aadb33SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -fsanitize=address") 64d6937ddcSinitlife SET(LIBS ${LIBS} -fsanitize=address) 6550aadb33SDmitri Tikhonov ENDIF() 665392f7a3SLiteSpeed Tech # Uncomment to enable cleartext protocol mode (no crypto): 675392f7a3SLiteSpeed Tech #SET (MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_ENABLE_HANDSHAKE_DISABLE=1") 6850aadb33SDmitri TikhonovELSE() 6950aadb33SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -O3 -g0") 7050aadb33SDmitri Tikhonov # Comment out the following line to compile out debug messages: 7150aadb33SDmitri Tikhonov #SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_LOWEST_LOG_LEVEL=LSQ_LOG_INFO") 7250aadb33SDmitri TikhonovENDIF() 7350aadb33SDmitri Tikhonov 7467b0dc15SDmitri TikhonovIF(LSQUIC_PROFILE EQUAL 1) 7567b0dc15SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -g -pg") 7667b0dc15SDmitri TikhonovENDIF() 7767b0dc15SDmitri Tikhonov 7816a9b66aSDmitri TikhonovIF(LSQUIC_COVERAGE EQUAL 1) 7916a9b66aSDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -fprofile-arcs -ftest-coverage") 8016a9b66aSDmitri TikhonovENDIF() 8116a9b66aSDmitri Tikhonov 8250aadb33SDmitri TikhonovIF(MY_CMAKE_FLAGS MATCHES "fsanitize=address") 8350aadb33SDmitri Tikhonov MESSAGE(STATUS "AddressSanitizer is ON") 8450aadb33SDmitri TikhonovELSE() 8550aadb33SDmitri Tikhonov MESSAGE(STATUS "AddressSanitizer is OFF") 8650aadb33SDmitri TikhonovENDIF() 8750aadb33SDmitri Tikhonov 88461e84d8SAmol Deshpande#MSVC 89461e84d8SAmol DeshpandeELSE() 90fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4100") # unreferenced formal parameter 91fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4115") # unnamed type definition in parentheses 92fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4116") # named type definition in parentheses 93fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4146") # unary minus operator applied to unsigned type, result still unsigned 94fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4132") # const initialization 95fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4200") # zero-sized array 96fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4204") # non-constant aggregate initializer 97fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4244") # integer conversion 98fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4245") # conversion from 'int' to 'unsigned int', signed/unsigned mismatch 99fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4267") # integer conversion 1002d296031SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4214") # nonstandard extension used: bit field types other than int 101fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4295") # array is too small to include a terminating null character 102fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4334") # result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) 103fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4456") # hide previous local declaration 104fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4459") # hide global declaration 105fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4706") # assignment within conditional expression 106461e84d8SAmol 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") 1071e75f938SDmitri TikhonovIF(CMAKE_BUILD_TYPE STREQUAL "Debug") 108b5d685fcSBob Perper SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Od") 109461e84d8SAmol Deshpande #SET (MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DFIU_ENABLE=1") 110ccd74161SDmitri Tikhonov #SET(LIBS ${LIBS} fiu) 111461e84d8SAmol DeshpandeELSE() 112b5d685fcSBob Perper SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Ox") 113461e84d8SAmol Deshpande # Comment out the following line to compile out debug messages: 114461e84d8SAmol Deshpande #SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_LOWEST_LOG_LEVEL=LSQ_LOG_INFO") 115461e84d8SAmol DeshpandeENDIF() 116461e84d8SAmol Deshpande 117461e84d8SAmol DeshpandeENDIF() #MSVC 118461e84d8SAmol Deshpande 11950aadb33SDmitri Tikhonovset(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_CMAKE_FLAGS} $ENV{EXTRA_CFLAGS}") 12050aadb33SDmitri Tikhonov 12150aadb33SDmitri TikhonovMESSAGE(STATUS "Compiler flags: ${CMAKE_C_FLAGS}") 12250aadb33SDmitri Tikhonov 123fb3e20e0SDmitri Tikhonovfind_package(Perl) 124fb3e20e0SDmitri TikhonovIF(NOT PERL_FOUND) 125fb3e20e0SDmitri Tikhonov MESSAGE(FATAL_ERROR "Perl not found -- need it to generate source code") 126fb3e20e0SDmitri TikhonovENDIF() 127fb3e20e0SDmitri Tikhonov 1282e1429b4SDmitri TikhonovIF(LSQUIC_SHARED_LIB) 1292e1429b4SDmitri Tikhonov SET(LIB_SUFFIX .so) 1302e1429b4SDmitri TikhonovELSE() 1312e1429b4SDmitri Tikhonov SET(LIB_SUFFIX .a) 1322e1429b4SDmitri TikhonovENDIF() 1332e1429b4SDmitri Tikhonov 1348ca33e0eSDmitri TikhonovIF (NOT DEFINED BORINGSSL_INCLUDE AND DEFINED BORINGSSL_DIR) 1358ca33e0eSDmitri Tikhonov FIND_PATH(BORINGSSL_INCLUDE NAMES openssl/ssl.h 1368ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_DIR}/include 1378ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1388ca33e0eSDmitri TikhonovENDIF() 139b1af35d6SDmitri Tikhonov# This must be done before adding other include directories to take 140b1af35d6SDmitri Tikhonov# precedence over header files from other SSL installs. 1418ca33e0eSDmitri Tikhonov 1428ca33e0eSDmitri TikhonovIF (BORINGSSL_INCLUDE) 1438ca33e0eSDmitri Tikhonov MESSAGE(STATUS "BoringSSL include directory ${BORINGSSL_INCLUDE}") 1448ca33e0eSDmitri Tikhonov INCLUDE_DIRECTORIES(${BORINGSSL_INCLUDE}) 145b1af35d6SDmitri TikhonovELSE() 146b1af35d6SDmitri Tikhonov MESSAGE(FATAL_ERROR "BoringSSL headers not found") 147e0197994SDmitri TikhonovENDIF() 14850aadb33SDmitri Tikhonov 1498ca33e0eSDmitri TikhonovIF (NOT DEFINED BORINGSSL_LIB AND DEFINED BORINGSSL_DIR) 1508ca33e0eSDmitri Tikhonov FOREACH(LIB_NAME ssl crypto decrepit) 1518ca33e0eSDmitri Tikhonov IF (CMAKE_SYSTEM_NAME STREQUAL Windows) 1528ca33e0eSDmitri Tikhonov FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 1538ca33e0eSDmitri Tikhonov NAMES ${LIB_NAME} 1548ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_DIR}/${LIB_NAME} 155fb3e20e0SDmitri Tikhonov PATH_SUFFIXES Debug Release MinSizeRel RelWithDebInfo 1568ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1578ca33e0eSDmitri Tikhonov ELSE() 1588ca33e0eSDmitri Tikhonov FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 1592e1429b4SDmitri Tikhonov NAMES lib${LIB_NAME}${LIB_SUFFIX} 1608ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_DIR}/${LIB_NAME} 1618ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1628ca33e0eSDmitri Tikhonov ENDIF() 1638ca33e0eSDmitri Tikhonov IF(BORINGSSL_LIB_${LIB_NAME}) 1648ca33e0eSDmitri Tikhonov MESSAGE(STATUS "Found ${LIB_NAME} library: ${BORINGSSL_LIB_${LIB_NAME}}") 1658ca33e0eSDmitri Tikhonov ELSE() 1668ca33e0eSDmitri Tikhonov MESSAGE(STATUS "${LIB_NAME} library not found") 1678ca33e0eSDmitri Tikhonov ENDIF() 1688ca33e0eSDmitri Tikhonov ENDFOREACH() 1698ca33e0eSDmitri Tikhonov 1708ca33e0eSDmitri TikhonovELSE() 1718ca33e0eSDmitri Tikhonov 1728ca33e0eSDmitri Tikhonov 1738ca33e0eSDmitri Tikhonov FOREACH(LIB_NAME ssl crypto decrepit) 1748ca33e0eSDmitri Tikhonov IF (CMAKE_SYSTEM_NAME STREQUAL Windows) 1758ca33e0eSDmitri Tikhonov FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 1768ca33e0eSDmitri Tikhonov NAMES ${LIB_NAME} 1778ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_LIB} 1788ca33e0eSDmitri Tikhonov PATH_SUFFIXES Debug Release MinSizeRel RelWithDebInfo 1798ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1808ca33e0eSDmitri Tikhonov ELSE() 1818ca33e0eSDmitri Tikhonov FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 1822e1429b4SDmitri Tikhonov NAMES lib${LIB_NAME}${LIB_SUFFIX} 1838ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_LIB} 18481558c3fSRahul Jadhav PATH_SUFFIXES ${LIB_NAME} 1858ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1868ca33e0eSDmitri Tikhonov ENDIF() 1878ca33e0eSDmitri Tikhonov IF(BORINGSSL_LIB_${LIB_NAME}) 1888ca33e0eSDmitri Tikhonov MESSAGE(STATUS "Found ${BORINGSSL_LIB} library: ${BORINGSSL_LIB_${LIB_NAME}}") 1898ca33e0eSDmitri Tikhonov ELSE() 1908ca33e0eSDmitri Tikhonov MESSAGE(STATUS "${BORINGSSL_LIB} library not found") 1918ca33e0eSDmitri Tikhonov ENDIF() 1928ca33e0eSDmitri Tikhonov ENDFOREACH() 193461e84d8SAmol Deshpande 1948ca33e0eSDmitri TikhonovENDIF() 1958ca33e0eSDmitri Tikhonov 1968ca33e0eSDmitri TikhonovSET(CMAKE_INCLUDE_CURRENT_DIR ON) 19783506617SDmitri TikhonovINCLUDE_DIRECTORIES(include) 198b1af35d6SDmitri TikhonovIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin") 19950aadb33SDmitri Tikhonov # Find libevent on FreeBSD: 2008ca33e0eSDmitri Tikhonov include_directories( /usr/local/include ) 2018ca33e0eSDmitri Tikhonov link_directories( /usr/local/lib ) 202b1af35d6SDmitri TikhonovENDIF() 203b1af35d6SDmitri Tikhonov 204b1af35d6SDmitri Tikhonov# Find zlib and libevent header files and library files 205b1af35d6SDmitri Tikhonov# TODO: libevent is not strictly necessary to build the library. 206b1af35d6SDmitri TikhonovFIND_PATH(ZLIB_INCLUDE_DIR NAMES zlib.h) 207b1af35d6SDmitri TikhonovIF (ZLIB_INCLUDE_DIR) 208b1af35d6SDmitri Tikhonov INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) 209b1af35d6SDmitri TikhonovELSE() 210b1af35d6SDmitri Tikhonov MESSAGE(FATAL_ERROR "zlib.h was not found") 211b1af35d6SDmitri TikhonovENDIF() 212b1af35d6SDmitri TikhonovIF (CMAKE_SYSTEM_NAME STREQUAL Windows) 213b1af35d6SDmitri Tikhonov FIND_LIBRARY(ZLIB_LIB zlib) 214b1af35d6SDmitri TikhonovELSEIF(CMAKE_SYSTEM_NAME STREQUAL Darwin) 215b1af35d6SDmitri Tikhonov # XXX somehow FIND_LIBRARY() does not find zlib on Travis? 216b1af35d6SDmitri Tikhonov SET(ZLIB_LIB z) 217b1af35d6SDmitri TikhonovELSE() 2182e1429b4SDmitri Tikhonov FIND_LIBRARY(ZLIB_LIB libz${LIB_SUFFIX}) 219b1af35d6SDmitri TikhonovENDIF() 220b1af35d6SDmitri TikhonovIF(ZLIB_LIB) 221b1af35d6SDmitri Tikhonov MESSAGE(STATUS "Found zlib: ${ZLIB_LIB}") 222b1af35d6SDmitri TikhonovELSE() 223b1af35d6SDmitri Tikhonov MESSAGE(STATUS "zlib not found") 224b1af35d6SDmitri TikhonovENDIF() 2259a690580SDmitri Tikhonov 226fb3e20e0SDmitri TikhonovIF (LSQUIC_BIN OR LSQUIC_TESTS) 227b1af35d6SDmitri TikhonovFIND_PATH(EVENT_INCLUDE_DIR NAMES event2/event.h) 228b1af35d6SDmitri TikhonovIF (EVENT_INCLUDE_DIR) 229b1af35d6SDmitri Tikhonov INCLUDE_DIRECTORIES(${EVENT_INCLUDE_DIR}) 230b1af35d6SDmitri TikhonovELSE() 231b1af35d6SDmitri Tikhonov MESSAGE(FATAL_ERROR "event2/event.h was not found") 232b1af35d6SDmitri TikhonovENDIF() 233b1af35d6SDmitri TikhonovIF (CMAKE_SYSTEM_NAME STREQUAL Windows) 234b1af35d6SDmitri Tikhonov FIND_LIBRARY(EVENT_LIB event) 235b1af35d6SDmitri TikhonovELSE() 2362e1429b4SDmitri Tikhonov FIND_LIBRARY(EVENT_LIB libevent${LIB_SUFFIX}) 237747be414SDmitri Tikhonov IF(NOT EVENT_LIB) 238747be414SDmitri Tikhonov FIND_LIBRARY(EVENT_LIB libevent.so) 239747be414SDmitri Tikhonov ENDIF() 240b1af35d6SDmitri TikhonovENDIF() 241b1af35d6SDmitri TikhonovIF(EVENT_LIB) 242b1af35d6SDmitri Tikhonov MESSAGE(STATUS "Found event: ${EVENT_LIB}") 243b1af35d6SDmitri TikhonovELSE() 244b1af35d6SDmitri Tikhonov MESSAGE(STATUS "libevent not found") 24550aadb33SDmitri TikhonovENDIF() 246fb3e20e0SDmitri TikhonovSET(LIBS lsquic ${EVENT_LIB} ${BORINGSSL_LIB_ssl} ${BORINGSSL_LIB_crypto} ${ZLIB_LIB} ${LIBS}) 247fb3e20e0SDmitri TikhonovIF(MSVC) 248fb3e20e0SDmitri TikhonovFIND_LIBRARY(PCRE_LIB pcre) 249fb3e20e0SDmitri TikhonovIF(PCRE_LIB) 250fb3e20e0SDmitri Tikhonov MESSAGE(STATUS "Found pcre: ${PCRE_LIB}") 251fb3e20e0SDmitri Tikhonov LIST(APPEND LIBS ${PCRE_LIB}) 252fb3e20e0SDmitri TikhonovELSE() 253fb3e20e0SDmitri Tikhonov MESSAGE(STATUS "pcre not found: http_server won't work") 254fb3e20e0SDmitri TikhonovENDIF() 255fb3e20e0SDmitri TikhonovFIND_LIBRARY(PCREPOSIX_LIB pcreposix) 256fb3e20e0SDmitri TikhonovIF(PCREPOSIX_LIB) 257fb3e20e0SDmitri Tikhonov MESSAGE(STATUS "Found pcreposix: ${PCREPOSIX_LIB}") 258fb3e20e0SDmitri Tikhonov LIST(APPEND LIBS ${PCREPOSIX_LIB}) 259fb3e20e0SDmitri TikhonovELSE() 260fb3e20e0SDmitri Tikhonov MESSAGE(STATUS "pcreposix not found: http_server won't work") 261fb3e20e0SDmitri TikhonovENDIF() 262fb3e20e0SDmitri TikhonovLIST(APPEND LIBS ws2_32) 263fb3e20e0SDmitri TikhonovENDIF() 264fb3e20e0SDmitri TikhonovENDIF() # LSQUIC_BIN OR LSQUIC_TESTS 26550aadb33SDmitri Tikhonov 266fb3e20e0SDmitri TikhonovIF(LSQUIC_BIN) 267fb3e20e0SDmitri TikhonovIF(MSVC) 268fb3e20e0SDmitri Tikhonov SET(GETOPT_C wincompat/getopt.c) 269fb3e20e0SDmitri TikhonovENDIF() 270fb3e20e0SDmitri Tikhonovadd_executable(http_server bin/http_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 271fb3e20e0SDmitri TikhonovIF(NOT MSVC) # TODO: port MD5 server and client to Windows 272fb3e20e0SDmitri Tikhonovadd_executable(md5_server bin/md5_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 273fb3e20e0SDmitri Tikhonovadd_executable(md5_client bin/md5_client.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 274fb3e20e0SDmitri TikhonovENDIF() 275fb3e20e0SDmitri Tikhonovadd_executable(echo_server bin/echo_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 276fb3e20e0SDmitri Tikhonovadd_executable(echo_client bin/echo_client.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 277b1a7c3f9SDmitri Tikhonovadd_executable(duck_server bin/duck_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 278b1a7c3f9SDmitri Tikhonovadd_executable(duck_client bin/duck_client.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C}) 2798ca33e0eSDmitri Tikhonov 280b93f59beSBob Perper 28146a5b669SDmitri TikhonovIF (NOT MSVC) 2825392f7a3SLiteSpeed Tech 283c51ce338SDmitri Tikhonovadd_executable(http_client 2849a690580SDmitri Tikhonov bin/http_client.c 2859a690580SDmitri Tikhonov bin/prog.c 2869a690580SDmitri Tikhonov bin/test_common.c 2879a690580SDmitri Tikhonov bin/test_cert.c 288c51ce338SDmitri Tikhonov) 2898ca33e0eSDmitri TikhonovLIST(APPEND LIBS pthread m) 29050aadb33SDmitri Tikhonov 2915d77f141SAmol Deshpande#MSVC 292461e84d8SAmol DeshpandeELSE() 2935392f7a3SLiteSpeed Tech 294461e84d8SAmol Deshpandeadd_executable(http_client 2959a690580SDmitri Tikhonov bin/http_client.c 2969a690580SDmitri Tikhonov bin/prog.c 2979a690580SDmitri Tikhonov bin/test_common.c 298fb3e20e0SDmitri Tikhonov bin/test_cert.c 299461e84d8SAmol Deshpande wincompat/getopt.c 300461e84d8SAmol Deshpande wincompat/getopt1.c 301461e84d8SAmol Deshpande) 3028ca33e0eSDmitri TikhonovLIST(APPEND LIBS ws2_32) 303461e84d8SAmol Deshpande 304461e84d8SAmol DeshpandeENDIF() 305461e84d8SAmol Deshpande 3068ca33e0eSDmitri TikhonovTARGET_LINK_LIBRARIES(http_client ${LIBS}) 3075392f7a3SLiteSpeed TechTARGET_LINK_LIBRARIES(http_server ${LIBS}) 308fb3e20e0SDmitri TikhonovIF(NOT MSVC) 3090adf085aSDmitri TikhonovTARGET_LINK_LIBRARIES(md5_server ${LIBS}) 3100adf085aSDmitri TikhonovTARGET_LINK_LIBRARIES(md5_client ${LIBS}) 311fb3e20e0SDmitri TikhonovENDIF() 3120adf085aSDmitri TikhonovTARGET_LINK_LIBRARIES(echo_server ${LIBS}) 3130adf085aSDmitri TikhonovTARGET_LINK_LIBRARIES(echo_client ${LIBS}) 314b1a7c3f9SDmitri TikhonovTARGET_LINK_LIBRARIES(duck_server ${LIBS}) 315b1a7c3f9SDmitri TikhonovTARGET_LINK_LIBRARIES(duck_client ${LIBS}) 31650aadb33SDmitri Tikhonov 3179a690580SDmitri Tikhonovadd_subdirectory(bin) 3189a690580SDmitri TikhonovENDIF() # LSQUIC_BIN 31950aadb33SDmitri Tikhonov 32021c6983aSRahul Jadhavadd_subdirectory(src) 32121c6983aSRahul Jadhav 3229a690580SDmitri TikhonovIF(LSQUIC_TESTS AND CMAKE_BUILD_TYPE STREQUAL "Debug") 3237fbe101bSDmitri Tikhonov # Our test framework relies on assertions, only compile if assertions are 3247fbe101bSDmitri Tikhonov # enabled. 3257fbe101bSDmitri Tikhonov # 3267fbe101bSDmitri Tikhonov enable_testing() 3279a690580SDmitri Tikhonov add_subdirectory(tests) 3287fbe101bSDmitri TikhonovENDIF() 3297fbe101bSDmitri Tikhonov 330feca77f5SDmitri Tikhonov 3310bd32030SDmitri TikhonovFIND_PROGRAM(SPHINX NAMES sphinx-build) 3320bd32030SDmitri TikhonovIF(SPHINX) 3330bd32030SDmitri Tikhonov ADD_CUSTOM_TARGET(docs 3340bd32030SDmitri Tikhonov ${SPHINX} -b html 3350bd32030SDmitri Tikhonov docs 3360bd32030SDmitri Tikhonov docs/_build 3370bd32030SDmitri Tikhonov ) 3380bd32030SDmitri TikhonovELSE() 3390bd32030SDmitri Tikhonov MESSAGE(STATUS "sphinx-build not found: docs won't be made") 3400bd32030SDmitri TikhonovENDIF() 341966c52fcSJonas Vautherin 342966c52fcSJonas VautherinINSTALL(FILES 343966c52fcSJonas Vautherin include/lsquic.h 344966c52fcSJonas Vautherin include/lsquic_types.h 345966c52fcSJonas Vautherin include/lsxpack_header.h 346966c52fcSJonas Vautherin DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lsquic 347966c52fcSJonas Vautherin) 348