CMakeLists.txt revision 61b4eaa6
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 15f07b3eaeSTyler YoungMESSAGE(STATUS "CMake v${CMAKE_VERSION}") 16f07b3eaeSTyler Young 1712693a01SDmitri TikhonovIF (CMAKE_SYSTEM_NAME STREQUAL "Linux") 1812693a01SDmitri Tikhonov # If using older glibc, need to link with -lrt. See clock_getres(2). 1912693a01SDmitri Tikhonov EXECUTE_PROCESS( 2012693a01SDmitri Tikhonov COMMAND ${PROJECT_SOURCE_DIR}/print-glibc-version.sh ${CMAKE_C_COMPILER} 2112693a01SDmitri Tikhonov OUTPUT_VARIABLE GLIBC_VERSION) 2212693a01SDmitri Tikhonov IF(NOT GLIBC_VERSION EQUAL "" AND GLIBC_VERSION VERSION_LESS 2.17) 2312693a01SDmitri Tikhonov SET(LIBS ${LIBS} rt) 2412693a01SDmitri Tikhonov ENDIF() 2521c6983aSRahul JadhavELSEIF (CMAKE_SYSTEM_NAME STREQUAL "Android") 2621c6983aSRahul Jadhav # for android-ndk >= r19b 2721c6983aSRahul Jadhav set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY "BOTH") 2821c6983aSRahul Jadhav set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE "BOTH") 2921c6983aSRahul Jadhav set(CMAKE_FIND_ROOT_PATH_MODE_PATH "BOTH") 30ccd74161SDmitri TikhonovENDIF() 31ccd74161SDmitri Tikhonov 321e75f938SDmitri TikhonovIF("${CMAKE_BUILD_TYPE}" STREQUAL "") 331e75f938SDmitri Tikhonov SET(CMAKE_BUILD_TYPE Debug) 3450aadb33SDmitri TikhonovENDIF() 3550aadb33SDmitri Tikhonov 361e75f938SDmitri TikhonovMESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}") 3750aadb33SDmitri Tikhonov 38a0e1aeeeSDmitri TikhonovIF (NOT "$ENV{EXTRA_CFLAGS}" MATCHES "-DLSQUIC_DEBUG_NEXT_ADV_TICK") 39a0e1aeeeSDmitri Tikhonov SET(MY_CMAKE_FLAGS "-DLSQUIC_DEBUG_NEXT_ADV_TICK=1") 40a0e1aeeeSDmitri TikhonovENDIF() 41b93f59beSBob Perper 42c0b26eabSDmitri TikhonovIF (NOT "$ENV{EXTRA_CFLAGS}" MATCHES "-DLSQUIC_CONN_STATS=") 43c0b26eabSDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_CONN_STATS=1") 44c0b26eabSDmitri TikhonovENDIF() 45c0b26eabSDmitri Tikhonov 4646a5b669SDmitri TikhonovIF (NOT MSVC) 47461e84d8SAmol Deshpande 4850aadb33SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wall -Wextra -Wno-unused-parameter") 4950aadb33SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -fno-omit-frame-pointer") 5050aadb33SDmitri Tikhonov 51e0197994SDmitri TikhonovIF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.3) 5250aadb33SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wno-missing-field-initializers") 5350aadb33SDmitri TikhonovENDIF() 545392f7a3SLiteSpeed Tech 55662de5e1SDmitri TikhonovIF(LSQUIC_FIU) 56662de5e1SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DFIU_ENABLE=1") 57662de5e1SDmitri Tikhonov SET(LIBS ${LIBS} fiu) 58662de5e1SDmitri TikhonovENDIF() 59662de5e1SDmitri Tikhonov 601e75f938SDmitri TikhonovIF(CMAKE_BUILD_TYPE STREQUAL "Debug") 6150aadb33SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -O0 -g3") 62db8ac9eeSDmitri Tikhonov IF(CMAKE_C_COMPILER MATCHES "clang" AND 6303e6b668SDmitri Tikhonov NOT "$ENV{TRAVIS}" MATCHES "^true$" AND 6403e6b668SDmitri Tikhonov NOT "$ENV{EXTRA_CFLAGS}" MATCHES "-fsanitize") 6550aadb33SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -fsanitize=address") 66d6937ddcSinitlife SET(LIBS ${LIBS} -fsanitize=address) 6750aadb33SDmitri Tikhonov ENDIF() 685392f7a3SLiteSpeed Tech # Uncomment to enable cleartext protocol mode (no crypto): 695392f7a3SLiteSpeed Tech #SET (MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_ENABLE_HANDSHAKE_DISABLE=1") 7050aadb33SDmitri TikhonovELSE() 7150aadb33SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -O3 -g0") 7250aadb33SDmitri Tikhonov # Comment out the following line to compile out debug messages: 7350aadb33SDmitri Tikhonov #SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_LOWEST_LOG_LEVEL=LSQ_LOG_INFO") 7450aadb33SDmitri TikhonovENDIF() 7550aadb33SDmitri Tikhonov 7600c58df3SDmitri TikhonovIF (LSQUIC_DEVEL) 7700c58df3SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_DEVEL=1") 7800c58df3SDmitri TikhonovENDIF() 7900c58df3SDmitri Tikhonov 8067b0dc15SDmitri TikhonovIF(LSQUIC_PROFILE EQUAL 1) 8167b0dc15SDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -g -pg") 8267b0dc15SDmitri TikhonovENDIF() 8367b0dc15SDmitri Tikhonov 8416a9b66aSDmitri TikhonovIF(LSQUIC_COVERAGE EQUAL 1) 8516a9b66aSDmitri Tikhonov SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -fprofile-arcs -ftest-coverage") 8616a9b66aSDmitri TikhonovENDIF() 8716a9b66aSDmitri Tikhonov 8850aadb33SDmitri TikhonovIF(MY_CMAKE_FLAGS MATCHES "fsanitize=address") 8950aadb33SDmitri Tikhonov MESSAGE(STATUS "AddressSanitizer is ON") 9050aadb33SDmitri TikhonovELSE() 9150aadb33SDmitri Tikhonov MESSAGE(STATUS "AddressSanitizer is OFF") 9250aadb33SDmitri TikhonovENDIF() 9350aadb33SDmitri Tikhonov 94461e84d8SAmol Deshpande#MSVC 95461e84d8SAmol DeshpandeELSE() 96fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4100") # unreferenced formal parameter 97fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4115") # unnamed type definition in parentheses 98fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4116") # named type definition in parentheses 99fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4146") # unary minus operator applied to unsigned type, result still unsigned 100fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4132") # const initialization 101fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4200") # zero-sized array 102fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4204") # non-constant aggregate initializer 103fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4244") # integer conversion 104fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4245") # conversion from 'int' to 'unsigned int', signed/unsigned mismatch 105fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4267") # integer conversion 1062d296031SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4214") # nonstandard extension used: bit field types other than int 107fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4295") # array is too small to include a terminating null character 108fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4334") # result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) 109fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4456") # hide previous local declaration 110fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4459") # hide global declaration 111fb3e20e0SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4706") # assignment within conditional expression 112464a1af9SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4090") # different 'const' qualifier (TODO: debug ls-sfparser.c) 11357fe5a13SDmitri TikhonovSET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4305") # truncation from double to float 114461e84d8SAmol 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") 115f07b3eaeSTyler YoungIF(LSQUIC_SHARED_LIB) 116f07b3eaeSTyler Young SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_SHARED_LIB") 117f07b3eaeSTyler YoungENDIF() 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 139f07b3eaeSTyler YoungIF (MSVC) 140f07b3eaeSTyler Young IF(LSQUIC_SHARED_LIB) 141f07b3eaeSTyler Young set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS YES CACHE BOOL "Export all symbols") 142f07b3eaeSTyler Young SET(LIB_SUFFIX .dll) 143f07b3eaeSTyler Young ELSE() 144f07b3eaeSTyler Young SET(LIB_SUFFIX .lib) 145f07b3eaeSTyler Young ENDIF() 1462e1429b4SDmitri TikhonovELSE() 147f07b3eaeSTyler Young IF(LSQUIC_SHARED_LIB) 148f07b3eaeSTyler Young SET(LIB_SUFFIX .so) 149f07b3eaeSTyler Young ELSE() 150f07b3eaeSTyler Young SET(LIB_SUFFIX .a) 151f07b3eaeSTyler Young ENDIF() 1522e1429b4SDmitri TikhonovENDIF() 1532e1429b4SDmitri Tikhonov 1548ca33e0eSDmitri TikhonovIF (NOT DEFINED BORINGSSL_INCLUDE AND DEFINED BORINGSSL_DIR) 1558ca33e0eSDmitri Tikhonov FIND_PATH(BORINGSSL_INCLUDE NAMES openssl/ssl.h 1568ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_DIR}/include 1578ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1588ca33e0eSDmitri TikhonovENDIF() 159b1af35d6SDmitri Tikhonov# This must be done before adding other include directories to take 160b1af35d6SDmitri Tikhonov# precedence over header files from other SSL installs. 1618ca33e0eSDmitri Tikhonov 1628ca33e0eSDmitri TikhonovIF (BORINGSSL_INCLUDE) 1638ca33e0eSDmitri Tikhonov MESSAGE(STATUS "BoringSSL include directory ${BORINGSSL_INCLUDE}") 1648ca33e0eSDmitri Tikhonov INCLUDE_DIRECTORIES(${BORINGSSL_INCLUDE}) 165b1af35d6SDmitri TikhonovELSE() 166b1af35d6SDmitri Tikhonov MESSAGE(FATAL_ERROR "BoringSSL headers not found") 167e0197994SDmitri TikhonovENDIF() 16850aadb33SDmitri Tikhonov 1698ca33e0eSDmitri TikhonovIF (NOT DEFINED BORINGSSL_LIB AND DEFINED BORINGSSL_DIR) 1708ca33e0eSDmitri Tikhonov FOREACH(LIB_NAME ssl crypto decrepit) 1718ca33e0eSDmitri Tikhonov IF (CMAKE_SYSTEM_NAME STREQUAL Windows) 1728ca33e0eSDmitri Tikhonov FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 1738ca33e0eSDmitri Tikhonov NAMES ${LIB_NAME} 1748ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_DIR}/${LIB_NAME} 175fb3e20e0SDmitri Tikhonov PATH_SUFFIXES Debug Release MinSizeRel RelWithDebInfo 1768ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1778ca33e0eSDmitri Tikhonov ELSE() 1788ca33e0eSDmitri Tikhonov FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 1792e1429b4SDmitri Tikhonov NAMES lib${LIB_NAME}${LIB_SUFFIX} 1808ca33e0eSDmitri Tikhonov PATHS ${BORINGSSL_DIR}/${LIB_NAME} 1818ca33e0eSDmitri Tikhonov NO_DEFAULT_PATH) 1828ca33e0eSDmitri Tikhonov ENDIF() 1838ca33e0eSDmitri Tikhonov IF(BORINGSSL_LIB_${LIB_NAME}) 1848ca33e0eSDmitri Tikhonov MESSAGE(STATUS "Found ${LIB_NAME} library: ${BORINGSSL_LIB_${LIB_NAME}}") 1858ca33e0eSDmitri Tikhonov ELSE() 1868ca33e0eSDmitri Tikhonov MESSAGE(STATUS "${LIB_NAME} library not found") 1878ca33e0eSDmitri Tikhonov ENDIF() 1888ca33e0eSDmitri Tikhonov ENDFOREACH() 1898ca33e0eSDmitri Tikhonov 1908ca33e0eSDmitri TikhonovELSE() 1918ca33e0eSDmitri Tikhonov 1928ca33e0eSDmitri Tikhonov 1938ca33e0eSDmitri Tikhonov FOREACH(LIB_NAME ssl crypto decrepit) 19461b4eaa6Squink-black # If BORINGSSL_LIB is defined, try find each lib. Otherwise, user should define BORINGSSL_LIB_ssl, 19561b4eaa6Squink-black # BORINGSSL_LIB_crypto and so on explicitly. For example, including boringssl and lsquic both via 19661b4eaa6Squink-black # add_subdirectory: 19761b4eaa6Squink-black # add_subdirectory(third_party/boringssl) 19861b4eaa6Squink-black # set(BORINGSSL_LIB_ssl ssl) 19961b4eaa6Squink-black # set(BORINGSSL_LIB_crypto crypto) 20061b4eaa6Squink-black # set(BORINGSSL_LIB_decrepit decrepit) 20161b4eaa6Squink-black # add_subdirectory(third_party/lsquic) 20261b4eaa6Squink-black IF (DEFINED BORINGSSL_LIB) 20361b4eaa6Squink-black IF (CMAKE_SYSTEM_NAME STREQUAL Windows) 20461b4eaa6Squink-black FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 20561b4eaa6Squink-black NAMES ${LIB_NAME} 20661b4eaa6Squink-black PATHS ${BORINGSSL_LIB} 20761b4eaa6Squink-black PATH_SUFFIXES Debug Release MinSizeRel RelWithDebInfo 20861b4eaa6Squink-black NO_DEFAULT_PATH) 20961b4eaa6Squink-black ELSE() 21061b4eaa6Squink-black FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} 21161b4eaa6Squink-black NAMES lib${LIB_NAME}${LIB_SUFFIX} 21261b4eaa6Squink-black PATHS ${BORINGSSL_LIB} 21361b4eaa6Squink-black PATH_SUFFIXES ${LIB_NAME} 21461b4eaa6Squink-black NO_DEFAULT_PATH) 21561b4eaa6Squink-black ENDIF() 2168ca33e0eSDmitri Tikhonov ENDIF() 2178ca33e0eSDmitri Tikhonov IF(BORINGSSL_LIB_${LIB_NAME}) 21861b4eaa6Squink-black MESSAGE(STATUS "Found ${LIB_NAME} library: ${BORINGSSL_LIB_${LIB_NAME}}") 2198ca33e0eSDmitri Tikhonov ELSE() 22061b4eaa6Squink-black MESSAGE(FATAL_ERROR "BORINGSSL_LIB_${LIB_NAME} library not found") 2218ca33e0eSDmitri Tikhonov ENDIF() 2228ca33e0eSDmitri Tikhonov ENDFOREACH() 223461e84d8SAmol Deshpande 2248ca33e0eSDmitri TikhonovENDIF() 2258ca33e0eSDmitri Tikhonov 2268ca33e0eSDmitri TikhonovSET(CMAKE_INCLUDE_CURRENT_DIR ON) 22783506617SDmitri TikhonovINCLUDE_DIRECTORIES(include) 228b1af35d6SDmitri TikhonovIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin") 22950aadb33SDmitri Tikhonov # Find libevent on FreeBSD: 2308ca33e0eSDmitri Tikhonov include_directories( /usr/local/include ) 2318ca33e0eSDmitri Tikhonov link_directories( /usr/local/lib ) 232b1af35d6SDmitri TikhonovENDIF() 233b1af35d6SDmitri Tikhonov 234f07b3eaeSTyler YoungIF (CMAKE_SYSTEM_NAME STREQUAL Windows) 235f07b3eaeSTyler Young FIND_PATH(GETOPT_INCLUDE_DIR NAMES getopt.h) 236f07b3eaeSTyler Young IF (GETOPT_INCLUDE_DIR) 237f07b3eaeSTyler Young INCLUDE_DIRECTORIES(${GETOPT_INCLUDE_DIR}) 238f07b3eaeSTyler Young ELSE() 239f07b3eaeSTyler Young MESSAGE(FATAL_ERROR "getopt.h was not found") 240f07b3eaeSTyler Young ENDIF() 241f07b3eaeSTyler Young FIND_LIBRARY(GETOPT_LIB getopt) 242f07b3eaeSTyler Young IF(GETOPT_LIB) 243f07b3eaeSTyler Young MESSAGE(STATUS "Found getopt: ${GETOPT_LIB}") 244f07b3eaeSTyler Young ELSE() 245f07b3eaeSTyler Young MESSAGE(STATUS "getopt not found") 246f07b3eaeSTyler Young ENDIF() 247f07b3eaeSTyler YoungENDIF() 248f07b3eaeSTyler Young 249b1af35d6SDmitri Tikhonov# Find zlib and libevent header files and library files 250b1af35d6SDmitri Tikhonov# TODO: libevent is not strictly necessary to build the library. 251b1af35d6SDmitri TikhonovFIND_PATH(ZLIB_INCLUDE_DIR NAMES zlib.h) 252b1af35d6SDmitri TikhonovIF (ZLIB_INCLUDE_DIR) 253b1af35d6SDmitri Tikhonov INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) 254b1af35d6SDmitri TikhonovELSE() 255b1af35d6SDmitri Tikhonov MESSAGE(FATAL_ERROR "zlib.h was not found") 256b1af35d6SDmitri TikhonovENDIF() 257b1af35d6SDmitri TikhonovIF (CMAKE_SYSTEM_NAME STREQUAL Windows) 258b1af35d6SDmitri Tikhonov FIND_LIBRARY(ZLIB_LIB zlib) 259b1af35d6SDmitri TikhonovELSEIF(CMAKE_SYSTEM_NAME STREQUAL Darwin) 260b1af35d6SDmitri Tikhonov # XXX somehow FIND_LIBRARY() does not find zlib on Travis? 261b1af35d6SDmitri Tikhonov SET(ZLIB_LIB z) 262b1af35d6SDmitri TikhonovELSE() 2632e1429b4SDmitri Tikhonov FIND_LIBRARY(ZLIB_LIB libz${LIB_SUFFIX}) 264b1af35d6SDmitri TikhonovENDIF() 265b1af35d6SDmitri TikhonovIF(ZLIB_LIB) 266b1af35d6SDmitri Tikhonov MESSAGE(STATUS "Found zlib: ${ZLIB_LIB}") 267b1af35d6SDmitri TikhonovELSE() 268b1af35d6SDmitri Tikhonov MESSAGE(STATUS "zlib not found") 269b1af35d6SDmitri TikhonovENDIF() 2709a690580SDmitri Tikhonov 271b54d1e63SDmitri TikhonovSET(LIBS lsquic ${BORINGSSL_LIB_ssl} ${BORINGSSL_LIB_crypto} ${ZLIB_LIB} ${LIBS}) 272b54d1e63SDmitri Tikhonov 273b54d1e63SDmitri TikhonovIF (LSQUIC_BIN) 274b54d1e63SDmitri Tikhonov FIND_PATH(EVENT_INCLUDE_DIR NAMES event2/event.h) 275b54d1e63SDmitri Tikhonov IF (EVENT_INCLUDE_DIR) 276b54d1e63SDmitri Tikhonov INCLUDE_DIRECTORIES(${EVENT_INCLUDE_DIR}) 277b54d1e63SDmitri Tikhonov ELSE() 278b54d1e63SDmitri Tikhonov MESSAGE(WARNING "event2/event.h was not found: binaries won't be built") 279b54d1e63SDmitri Tikhonov SET(LSQUIC_BIN OFF) 280747be414SDmitri Tikhonov ENDIF() 281b1af35d6SDmitri TikhonovENDIF() 28250aadb33SDmitri Tikhonov 283b54d1e63SDmitri TikhonovIF (LSQUIC_BIN) 284b54d1e63SDmitri Tikhonov IF (CMAKE_SYSTEM_NAME STREQUAL Windows) 285b54d1e63SDmitri Tikhonov FIND_LIBRARY(EVENT_LIB event) 286b54d1e63SDmitri Tikhonov ELSE() 287b54d1e63SDmitri Tikhonov FIND_LIBRARY(EVENT_LIB libevent${LIB_SUFFIX}) 288b54d1e63SDmitri Tikhonov IF(NOT EVENT_LIB) 289b54d1e63SDmitri Tikhonov FIND_LIBRARY(EVENT_LIB libevent.so) 290b54d1e63SDmitri Tikhonov ENDIF() 291b54d1e63SDmitri Tikhonov ENDIF() 292b54d1e63SDmitri Tikhonov IF(EVENT_LIB) 293b54d1e63SDmitri Tikhonov MESSAGE(STATUS "Found event: ${EVENT_LIB}") 294b54d1e63SDmitri Tikhonov ELSE() 295b54d1e63SDmitri Tikhonov MESSAGE(WARNING "libevent not found: binaries won't be built") 296b54d1e63SDmitri Tikhonov SET(LSQUIC_BIN OFF) 297b54d1e63SDmitri Tikhonov ENDIF() 298fb3e20e0SDmitri TikhonovENDIF() 2998ca33e0eSDmitri Tikhonov 300b93f59beSBob Perper 30146a5b669SDmitri TikhonovIF (NOT MSVC) 302b54d1e63SDmitri Tikhonov LIST(APPEND LIBS pthread m) 303461e84d8SAmol DeshpandeELSE() 304b54d1e63SDmitri Tikhonov LIST(APPEND LIBS ws2_32) 305461e84d8SAmol DeshpandeENDIF() 306461e84d8SAmol Deshpande 307b54d1e63SDmitri TikhonovIF (LSQUIC_BIN) 308b54d1e63SDmitri Tikhonov ADD_SUBDIRECTORY(bin) 309fb3e20e0SDmitri TikhonovENDIF() 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() 332966c52fcSJonas Vautherin 333966c52fcSJonas VautherinINSTALL(FILES 334966c52fcSJonas Vautherin include/lsquic.h 335966c52fcSJonas Vautherin include/lsquic_types.h 336966c52fcSJonas Vautherin include/lsxpack_header.h 337966c52fcSJonas Vautherin DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lsquic 338966c52fcSJonas Vautherin) 339