2021-01-06 14:00:05 +00:00
|
|
|
# Copyright (c) 2017 - 2021 LiteSpeed Technologies Inc. See LICENSE.
|
2017-09-22 21:00:03 +00:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
|
|
|
|
|
2019-02-01 07:12:06 +00:00
|
|
|
PROJECT(lsquic C)
|
2018-03-12 22:25:01 +00:00
|
|
|
|
2020-05-17 16:42:32 +00:00
|
|
|
OPTION(LSQUIC_FIU "Use Fault Injection in Userspace (FIU)" OFF)
|
|
|
|
OPTION(LSQUIC_BIN "Compile example binaries that use the library" ON)
|
|
|
|
OPTION(LSQUIC_TESTS "Compile library unit tests" ON)
|
2020-09-25 18:09:10 +00:00
|
|
|
OPTION(LSQUIC_SHARED_LIB "Compile as shared librarry" OFF)
|
2020-10-08 13:28:24 +00:00
|
|
|
OPTION(LSQUIC_DEVEL "Compile in development mode" OFF)
|
2020-05-17 16:42:32 +00:00
|
|
|
|
2020-10-01 12:45:41 +00:00
|
|
|
INCLUDE(GNUInstallDirs)
|
|
|
|
|
2019-01-29 06:55:01 +00:00
|
|
|
IF (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
|
|
# If using older glibc, need to link with -lrt. See clock_getres(2).
|
|
|
|
EXECUTE_PROCESS(
|
|
|
|
COMMAND ${PROJECT_SOURCE_DIR}/print-glibc-version.sh ${CMAKE_C_COMPILER}
|
|
|
|
OUTPUT_VARIABLE GLIBC_VERSION)
|
|
|
|
IF(NOT GLIBC_VERSION EQUAL "" AND GLIBC_VERSION VERSION_LESS 2.17)
|
|
|
|
SET(LIBS ${LIBS} rt)
|
|
|
|
ENDIF()
|
2020-05-16 12:04:38 +00:00
|
|
|
ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "Android")
|
|
|
|
# for android-ndk >= r19b
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY "BOTH")
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE "BOTH")
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_PATH "BOTH")
|
2018-07-10 15:51:45 +00:00
|
|
|
ENDIF()
|
|
|
|
|
2018-10-16 13:03:33 +00:00
|
|
|
IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
|
|
|
SET(CMAKE_BUILD_TYPE Debug)
|
2017-09-22 21:00:03 +00:00
|
|
|
ENDIF()
|
|
|
|
|
2018-10-16 13:03:33 +00:00
|
|
|
MESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
|
2017-09-22 21:00:03 +00:00
|
|
|
|
2019-10-31 16:21:14 +00:00
|
|
|
IF (NOT "$ENV{EXTRA_CFLAGS}" MATCHES "-DLSQUIC_DEBUG_NEXT_ADV_TICK")
|
|
|
|
SET(MY_CMAKE_FLAGS "-DLSQUIC_DEBUG_NEXT_ADV_TICK=1")
|
|
|
|
ENDIF()
|
2018-03-30 14:57:17 +00:00
|
|
|
|
2020-10-21 14:20:19 +00:00
|
|
|
IF (NOT "$ENV{EXTRA_CFLAGS}" MATCHES "-DLSQUIC_CONN_STATS=")
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_CONN_STATS=1")
|
|
|
|
ENDIF()
|
|
|
|
|
2018-04-19 14:37:58 +00:00
|
|
|
IF (NOT MSVC)
|
2018-03-12 22:25:01 +00:00
|
|
|
|
2017-09-22 21:00:03 +00:00
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wall -Wextra -Wno-unused-parameter")
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -fno-omit-frame-pointer")
|
2019-09-11 15:27:58 +00:00
|
|
|
INCLUDE(CheckCCompilerFlag)
|
|
|
|
CHECK_C_COMPILER_FLAG(-Wno-implicit-fallthrough HAS_NO_IMPLICIT_FALLTHROUGH)
|
|
|
|
IF (HAS_NO_IMPLICIT_FALLTHROUGH)
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wno-implicit-fallthrough")
|
|
|
|
ENDIF()
|
2017-09-22 21:00:03 +00:00
|
|
|
|
2017-09-26 15:26:05 +00:00
|
|
|
IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.3)
|
2017-09-22 21:00:03 +00:00
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wno-missing-field-initializers")
|
|
|
|
ENDIF()
|
2019-09-11 15:27:58 +00:00
|
|
|
|
2019-10-08 12:36:49 +00:00
|
|
|
IF(LSQUIC_FIU)
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DFIU_ENABLE=1")
|
|
|
|
SET(LIBS ${LIBS} fiu)
|
|
|
|
ENDIF()
|
|
|
|
|
2018-10-16 13:03:33 +00:00
|
|
|
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2017-09-22 21:00:03 +00:00
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -O0 -g3")
|
2018-04-23 18:13:20 +00:00
|
|
|
IF(CMAKE_C_COMPILER MATCHES "clang" AND
|
2019-11-07 21:19:03 +00:00
|
|
|
NOT "$ENV{TRAVIS}" MATCHES "^true$" AND
|
|
|
|
NOT "$ENV{EXTRA_CFLAGS}" MATCHES "-fsanitize")
|
2017-09-22 21:00:03 +00:00
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -fsanitize=address")
|
2019-12-06 13:49:48 +00:00
|
|
|
SET(LIBS ${LIBS} -fsanitize=address)
|
2017-09-22 21:00:03 +00:00
|
|
|
ENDIF()
|
2019-09-11 15:27:58 +00:00
|
|
|
# Uncomment to enable cleartext protocol mode (no crypto):
|
|
|
|
#SET (MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_ENABLE_HANDSHAKE_DISABLE=1")
|
2017-09-22 21:00:03 +00:00
|
|
|
ELSE()
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -O3 -g0")
|
|
|
|
# Comment out the following line to compile out debug messages:
|
|
|
|
#SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_LOWEST_LOG_LEVEL=LSQ_LOG_INFO")
|
|
|
|
ENDIF()
|
|
|
|
|
2020-10-08 13:28:24 +00:00
|
|
|
IF (LSQUIC_DEVEL)
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_DEVEL=1")
|
|
|
|
ENDIF()
|
|
|
|
|
2017-09-29 15:18:32 +00:00
|
|
|
IF(LSQUIC_PROFILE EQUAL 1)
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -g -pg")
|
|
|
|
ENDIF()
|
|
|
|
|
2018-03-09 19:17:39 +00:00
|
|
|
IF(LSQUIC_COVERAGE EQUAL 1)
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -fprofile-arcs -ftest-coverage")
|
|
|
|
ENDIF()
|
|
|
|
|
2017-09-22 21:00:03 +00:00
|
|
|
IF(MY_CMAKE_FLAGS MATCHES "fsanitize=address")
|
|
|
|
MESSAGE(STATUS "AddressSanitizer is ON")
|
|
|
|
ELSE()
|
|
|
|
MESSAGE(STATUS "AddressSanitizer is OFF")
|
|
|
|
ENDIF()
|
|
|
|
|
2018-03-12 22:25:01 +00:00
|
|
|
#MSVC
|
|
|
|
ELSE()
|
2020-06-03 04:13:30 +00:00
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4100") # unreferenced formal parameter
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4115") # unnamed type definition in parentheses
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4116") # named type definition in parentheses
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4146") # unary minus operator applied to unsigned type, result still unsigned
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4132") # const initialization
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4200") # zero-sized array
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4204") # non-constant aggregate initializer
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4244") # integer conversion
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4245") # conversion from 'int' to 'unsigned int', signed/unsigned mismatch
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4267") # integer conversion
|
2019-01-30 20:28:35 +00:00
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4214") # nonstandard extension used: bit field types other than int
|
2020-06-03 04:13:30 +00:00
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4295") # array is too small to include a terminating null character
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4334") # result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4456") # hide previous local declaration
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4459") # hide global declaration
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4706") # assignment within conditional expression
|
2020-10-07 15:05:18 +00:00
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4090") # different 'const' qualifier (TODO: debug ls-sfparser.c)
|
2020-11-24 14:09:13 +00:00
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} /wd4305") # truncation from double to float
|
2018-03-12 22:25:01 +00:00
|
|
|
SET(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")
|
2018-10-16 13:03:33 +00:00
|
|
|
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2018-04-02 15:38:44 +00:00
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Od")
|
2018-03-12 22:25:01 +00:00
|
|
|
#SET (MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DFIU_ENABLE=1")
|
2018-07-10 15:51:45 +00:00
|
|
|
#SET(LIBS ${LIBS} fiu)
|
2018-03-12 22:25:01 +00:00
|
|
|
ELSE()
|
2018-04-02 15:38:44 +00:00
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Ox")
|
2018-03-12 22:25:01 +00:00
|
|
|
# Comment out the following line to compile out debug messages:
|
|
|
|
#SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_LOWEST_LOG_LEVEL=LSQ_LOG_INFO")
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
ENDIF() #MSVC
|
|
|
|
|
2017-09-22 21:00:03 +00:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_CMAKE_FLAGS} $ENV{EXTRA_CFLAGS}")
|
|
|
|
|
|
|
|
MESSAGE(STATUS "Compiler flags: ${CMAKE_C_FLAGS}")
|
|
|
|
|
2020-06-03 04:13:30 +00:00
|
|
|
find_package(Perl)
|
|
|
|
IF(NOT PERL_FOUND)
|
|
|
|
MESSAGE(FATAL_ERROR "Perl not found -- need it to generate source code")
|
|
|
|
ENDIF()
|
|
|
|
|
2020-09-25 18:09:10 +00:00
|
|
|
IF(LSQUIC_SHARED_LIB)
|
|
|
|
SET(LIB_SUFFIX .so)
|
|
|
|
ELSE()
|
|
|
|
SET(LIB_SUFFIX .a)
|
|
|
|
ENDIF()
|
|
|
|
|
2019-02-04 13:59:11 +00:00
|
|
|
IF (NOT DEFINED BORINGSSL_INCLUDE AND DEFINED BORINGSSL_DIR)
|
|
|
|
FIND_PATH(BORINGSSL_INCLUDE NAMES openssl/ssl.h
|
|
|
|
PATHS ${BORINGSSL_DIR}/include
|
|
|
|
NO_DEFAULT_PATH)
|
|
|
|
ENDIF()
|
2019-02-01 07:12:06 +00:00
|
|
|
# This must be done before adding other include directories to take
|
|
|
|
# precedence over header files from other SSL installs.
|
2019-02-04 13:59:11 +00:00
|
|
|
|
|
|
|
IF (BORINGSSL_INCLUDE)
|
|
|
|
MESSAGE(STATUS "BoringSSL include directory ${BORINGSSL_INCLUDE}")
|
|
|
|
INCLUDE_DIRECTORIES(${BORINGSSL_INCLUDE})
|
2019-02-01 07:12:06 +00:00
|
|
|
ELSE()
|
|
|
|
MESSAGE(FATAL_ERROR "BoringSSL headers not found")
|
2017-09-26 15:26:05 +00:00
|
|
|
ENDIF()
|
2017-09-22 21:00:03 +00:00
|
|
|
|
2019-02-04 13:59:11 +00:00
|
|
|
IF (NOT DEFINED BORINGSSL_LIB AND DEFINED BORINGSSL_DIR)
|
|
|
|
FOREACH(LIB_NAME ssl crypto decrepit)
|
|
|
|
IF (CMAKE_SYSTEM_NAME STREQUAL Windows)
|
|
|
|
FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME}
|
|
|
|
NAMES ${LIB_NAME}
|
|
|
|
PATHS ${BORINGSSL_DIR}/${LIB_NAME}
|
2020-06-03 04:13:30 +00:00
|
|
|
PATH_SUFFIXES Debug Release MinSizeRel RelWithDebInfo
|
2019-02-04 13:59:11 +00:00
|
|
|
NO_DEFAULT_PATH)
|
|
|
|
ELSE()
|
|
|
|
FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME}
|
2020-09-25 18:09:10 +00:00
|
|
|
NAMES lib${LIB_NAME}${LIB_SUFFIX}
|
2019-02-04 13:59:11 +00:00
|
|
|
PATHS ${BORINGSSL_DIR}/${LIB_NAME}
|
|
|
|
NO_DEFAULT_PATH)
|
|
|
|
ENDIF()
|
|
|
|
IF(BORINGSSL_LIB_${LIB_NAME})
|
|
|
|
MESSAGE(STATUS "Found ${LIB_NAME} library: ${BORINGSSL_LIB_${LIB_NAME}}")
|
|
|
|
ELSE()
|
|
|
|
MESSAGE(STATUS "${LIB_NAME} library not found")
|
|
|
|
ENDIF()
|
|
|
|
ENDFOREACH()
|
|
|
|
|
|
|
|
ELSE()
|
|
|
|
|
|
|
|
|
|
|
|
FOREACH(LIB_NAME ssl crypto decrepit)
|
|
|
|
IF (CMAKE_SYSTEM_NAME STREQUAL Windows)
|
|
|
|
FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME}
|
|
|
|
NAMES ${LIB_NAME}
|
|
|
|
PATHS ${BORINGSSL_LIB}
|
|
|
|
PATH_SUFFIXES Debug Release MinSizeRel RelWithDebInfo
|
|
|
|
NO_DEFAULT_PATH)
|
|
|
|
ELSE()
|
|
|
|
FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME}
|
2020-09-25 18:09:10 +00:00
|
|
|
NAMES lib${LIB_NAME}${LIB_SUFFIX}
|
2019-02-04 13:59:11 +00:00
|
|
|
PATHS ${BORINGSSL_LIB}
|
2020-05-19 19:18:30 +00:00
|
|
|
PATH_SUFFIXES ${LIB_NAME}
|
2019-02-04 13:59:11 +00:00
|
|
|
NO_DEFAULT_PATH)
|
|
|
|
ENDIF()
|
|
|
|
IF(BORINGSSL_LIB_${LIB_NAME})
|
|
|
|
MESSAGE(STATUS "Found ${BORINGSSL_LIB} library: ${BORINGSSL_LIB_${LIB_NAME}}")
|
|
|
|
ELSE()
|
|
|
|
MESSAGE(STATUS "${BORINGSSL_LIB} library not found")
|
|
|
|
ENDIF()
|
|
|
|
ENDFOREACH()
|
2018-03-12 22:25:01 +00:00
|
|
|
|
2019-02-04 13:59:11 +00:00
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
|
2020-02-20 22:00:23 +00:00
|
|
|
INCLUDE_DIRECTORIES(include)
|
2019-02-01 07:12:06 +00:00
|
|
|
IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
2017-09-22 21:00:03 +00:00
|
|
|
# Find libevent on FreeBSD:
|
2019-02-04 13:59:11 +00:00
|
|
|
include_directories( /usr/local/include )
|
|
|
|
link_directories( /usr/local/lib )
|
2019-02-01 07:12:06 +00:00
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
# Find zlib and libevent header files and library files
|
|
|
|
# TODO: libevent is not strictly necessary to build the library.
|
|
|
|
FIND_PATH(ZLIB_INCLUDE_DIR NAMES zlib.h)
|
|
|
|
IF (ZLIB_INCLUDE_DIR)
|
|
|
|
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
|
|
|
|
ELSE()
|
|
|
|
MESSAGE(FATAL_ERROR "zlib.h was not found")
|
|
|
|
ENDIF()
|
|
|
|
IF (CMAKE_SYSTEM_NAME STREQUAL Windows)
|
|
|
|
FIND_LIBRARY(ZLIB_LIB zlib)
|
|
|
|
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
|
|
|
# XXX somehow FIND_LIBRARY() does not find zlib on Travis?
|
|
|
|
SET(ZLIB_LIB z)
|
|
|
|
ELSE()
|
2020-09-25 18:09:10 +00:00
|
|
|
FIND_LIBRARY(ZLIB_LIB libz${LIB_SUFFIX})
|
2019-02-01 07:12:06 +00:00
|
|
|
ENDIF()
|
|
|
|
IF(ZLIB_LIB)
|
|
|
|
MESSAGE(STATUS "Found zlib: ${ZLIB_LIB}")
|
|
|
|
ELSE()
|
|
|
|
MESSAGE(STATUS "zlib not found")
|
|
|
|
ENDIF()
|
2020-05-17 16:42:32 +00:00
|
|
|
|
2020-06-03 04:13:30 +00:00
|
|
|
IF (LSQUIC_BIN OR LSQUIC_TESTS)
|
2019-02-01 07:12:06 +00:00
|
|
|
FIND_PATH(EVENT_INCLUDE_DIR NAMES event2/event.h)
|
|
|
|
IF (EVENT_INCLUDE_DIR)
|
|
|
|
INCLUDE_DIRECTORIES(${EVENT_INCLUDE_DIR})
|
|
|
|
ELSE()
|
|
|
|
MESSAGE(FATAL_ERROR "event2/event.h was not found")
|
|
|
|
ENDIF()
|
|
|
|
IF (CMAKE_SYSTEM_NAME STREQUAL Windows)
|
|
|
|
FIND_LIBRARY(EVENT_LIB event)
|
|
|
|
ELSE()
|
2020-09-25 18:09:10 +00:00
|
|
|
FIND_LIBRARY(EVENT_LIB libevent${LIB_SUFFIX})
|
2020-01-06 05:47:12 +00:00
|
|
|
IF(NOT EVENT_LIB)
|
|
|
|
FIND_LIBRARY(EVENT_LIB libevent.so)
|
|
|
|
ENDIF()
|
2019-02-01 07:12:06 +00:00
|
|
|
ENDIF()
|
|
|
|
IF(EVENT_LIB)
|
|
|
|
MESSAGE(STATUS "Found event: ${EVENT_LIB}")
|
|
|
|
ELSE()
|
|
|
|
MESSAGE(STATUS "libevent not found")
|
2017-09-22 21:00:03 +00:00
|
|
|
ENDIF()
|
2020-06-03 04:13:30 +00:00
|
|
|
SET(LIBS lsquic ${EVENT_LIB} ${BORINGSSL_LIB_ssl} ${BORINGSSL_LIB_crypto} ${ZLIB_LIB} ${LIBS})
|
|
|
|
IF(MSVC)
|
|
|
|
FIND_LIBRARY(PCRE_LIB pcre)
|
|
|
|
IF(PCRE_LIB)
|
|
|
|
MESSAGE(STATUS "Found pcre: ${PCRE_LIB}")
|
|
|
|
LIST(APPEND LIBS ${PCRE_LIB})
|
|
|
|
ELSE()
|
|
|
|
MESSAGE(STATUS "pcre not found: http_server won't work")
|
|
|
|
ENDIF()
|
|
|
|
FIND_LIBRARY(PCREPOSIX_LIB pcreposix)
|
|
|
|
IF(PCREPOSIX_LIB)
|
|
|
|
MESSAGE(STATUS "Found pcreposix: ${PCREPOSIX_LIB}")
|
|
|
|
LIST(APPEND LIBS ${PCREPOSIX_LIB})
|
|
|
|
ELSE()
|
|
|
|
MESSAGE(STATUS "pcreposix not found: http_server won't work")
|
|
|
|
ENDIF()
|
|
|
|
LIST(APPEND LIBS ws2_32)
|
2020-12-17 19:39:51 +00:00
|
|
|
LIST(APPEND LIBS iphlpapi)
|
2020-06-03 04:13:30 +00:00
|
|
|
ENDIF()
|
|
|
|
ENDIF() # LSQUIC_BIN OR LSQUIC_TESTS
|
2017-09-22 21:00:03 +00:00
|
|
|
|
2020-06-03 04:13:30 +00:00
|
|
|
IF(LSQUIC_BIN)
|
|
|
|
IF(MSVC)
|
|
|
|
SET(GETOPT_C wincompat/getopt.c)
|
|
|
|
ENDIF()
|
|
|
|
add_executable(http_server bin/http_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C})
|
|
|
|
IF(NOT MSVC) # TODO: port MD5 server and client to Windows
|
|
|
|
add_executable(md5_server bin/md5_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C})
|
|
|
|
add_executable(md5_client bin/md5_client.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C})
|
|
|
|
ENDIF()
|
|
|
|
add_executable(echo_server bin/echo_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C})
|
|
|
|
add_executable(echo_client bin/echo_client.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C})
|
2020-09-15 20:42:13 +00:00
|
|
|
add_executable(duck_server bin/duck_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C})
|
|
|
|
add_executable(duck_client bin/duck_client.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C})
|
2019-02-04 13:59:11 +00:00
|
|
|
|
2018-03-30 14:57:17 +00:00
|
|
|
|
2018-04-19 14:37:58 +00:00
|
|
|
IF (NOT MSVC)
|
2019-09-11 15:27:58 +00:00
|
|
|
|
Latest changes
- [API Change] Sendfile-like functionality is gone. The stream no
longer opens files and deals with file descriptors. (Among other
things, this makes the code more portable.) Three writing functions
are provided:
lsquic_stream_write
lsquic_stream_writev
lsquic_stream_writef (NEW)
lsquic_stream_writef() is given an abstract reader that has function
pointers for size() and read() functions which the user can implement.
This is the most flexible way. lsquic_stream_write() and
lsquic_stream_writev() are now both implemented as wrappers around
lsquic_stream_writef().
- [OPTIMIZATION] When writing to stream, be it within or without the
on_write() callback, place data directly into packet buffer,
bypassing auxiliary data structures. This reduces amount of memory
required, for the amount of data that can be written is limited
by the congestion window.
To support writes outside the on_write() callback, we keep N
outgoing packet buffers per connection which can be written to
by any stream. One half of these are reserved for the highest
priority stream(s), the other half for all other streams. This way,
low-priority streams cannot write instead of high-priority streams
and, on the other hand, low-priority streams get a chance to send
their packets out.
The algorithm is as follows:
- When user writes to stream outside of the callback:
- If this is the highest priority stream, place it onto the
reserved N/2 queue or fail.
(The actual size of this queue is dynamic -- MAX(N/2, CWND) --
rather than N/2, allowing high-priority streams to write as
much as can be sent.)
- If the stream is not the highest priority, try to place the
data onto the reserved N/2 queue or fail.
- When tick occurs *and* more packets can be scheduled:
- Transfer packets from the high N/2 queue to the scheduled
queue.
- If more scheduling is allowed:
- Call on_write callbacks for highest-priority streams,
placing resulting packets directly onto the scheduled queue.
- If more scheduling is allowed:
- Transfer packets from the low N/2 queue to the scheduled
queue.
- If more scheduling is allowed:
- Call on_write callbacks for non-highest-priority streams,
placing resulting packets directly onto the scheduled queue
The number N is currently 20, but it could be varied based on
resource usage.
- If stream is created due to incoming headers, make headers readable
from on_new.
- Outgoing packets are no longer marked non-writeable to prevent placing
more than one STREAM frame from the same stream into a single packet.
This property is maintained via code flow and an explicit check.
Packets for stream data are allocated using a special function.
- STREAM frame elision is cheaper, as we only perform it if a reset
stream has outgoing packets referencing it.
- lsquic_packet_out_t is smaller, as stream_rec elements are now
inside a union.
2017-10-31 13:35:58 +00:00
|
|
|
add_executable(http_client
|
2020-05-17 16:42:32 +00:00
|
|
|
bin/http_client.c
|
|
|
|
bin/prog.c
|
|
|
|
bin/test_common.c
|
|
|
|
bin/test_cert.c
|
Latest changes
- [API Change] Sendfile-like functionality is gone. The stream no
longer opens files and deals with file descriptors. (Among other
things, this makes the code more portable.) Three writing functions
are provided:
lsquic_stream_write
lsquic_stream_writev
lsquic_stream_writef (NEW)
lsquic_stream_writef() is given an abstract reader that has function
pointers for size() and read() functions which the user can implement.
This is the most flexible way. lsquic_stream_write() and
lsquic_stream_writev() are now both implemented as wrappers around
lsquic_stream_writef().
- [OPTIMIZATION] When writing to stream, be it within or without the
on_write() callback, place data directly into packet buffer,
bypassing auxiliary data structures. This reduces amount of memory
required, for the amount of data that can be written is limited
by the congestion window.
To support writes outside the on_write() callback, we keep N
outgoing packet buffers per connection which can be written to
by any stream. One half of these are reserved for the highest
priority stream(s), the other half for all other streams. This way,
low-priority streams cannot write instead of high-priority streams
and, on the other hand, low-priority streams get a chance to send
their packets out.
The algorithm is as follows:
- When user writes to stream outside of the callback:
- If this is the highest priority stream, place it onto the
reserved N/2 queue or fail.
(The actual size of this queue is dynamic -- MAX(N/2, CWND) --
rather than N/2, allowing high-priority streams to write as
much as can be sent.)
- If the stream is not the highest priority, try to place the
data onto the reserved N/2 queue or fail.
- When tick occurs *and* more packets can be scheduled:
- Transfer packets from the high N/2 queue to the scheduled
queue.
- If more scheduling is allowed:
- Call on_write callbacks for highest-priority streams,
placing resulting packets directly onto the scheduled queue.
- If more scheduling is allowed:
- Transfer packets from the low N/2 queue to the scheduled
queue.
- If more scheduling is allowed:
- Call on_write callbacks for non-highest-priority streams,
placing resulting packets directly onto the scheduled queue
The number N is currently 20, but it could be varied based on
resource usage.
- If stream is created due to incoming headers, make headers readable
from on_new.
- Outgoing packets are no longer marked non-writeable to prevent placing
more than one STREAM frame from the same stream into a single packet.
This property is maintained via code flow and an explicit check.
Packets for stream data are allocated using a special function.
- STREAM frame elision is cheaper, as we only perform it if a reset
stream has outgoing packets referencing it.
- lsquic_packet_out_t is smaller, as stream_rec elements are now
inside a union.
2017-10-31 13:35:58 +00:00
|
|
|
)
|
2019-02-04 13:59:11 +00:00
|
|
|
LIST(APPEND LIBS pthread m)
|
2017-09-22 21:00:03 +00:00
|
|
|
|
2018-03-13 02:56:06 +00:00
|
|
|
#MSVC
|
2018-03-12 22:25:01 +00:00
|
|
|
ELSE()
|
2019-09-11 15:27:58 +00:00
|
|
|
|
2018-03-12 22:25:01 +00:00
|
|
|
add_executable(http_client
|
2020-05-17 16:42:32 +00:00
|
|
|
bin/http_client.c
|
|
|
|
bin/prog.c
|
|
|
|
bin/test_common.c
|
2020-06-03 04:13:30 +00:00
|
|
|
bin/test_cert.c
|
2018-03-12 22:25:01 +00:00
|
|
|
wincompat/getopt.c
|
|
|
|
wincompat/getopt1.c
|
|
|
|
)
|
2019-02-04 13:59:11 +00:00
|
|
|
LIST(APPEND LIBS ws2_32)
|
2018-03-12 22:25:01 +00:00
|
|
|
|
|
|
|
ENDIF()
|
|
|
|
|
2019-02-04 13:59:11 +00:00
|
|
|
TARGET_LINK_LIBRARIES(http_client ${LIBS})
|
2019-09-11 15:27:58 +00:00
|
|
|
TARGET_LINK_LIBRARIES(http_server ${LIBS})
|
2020-06-03 04:13:30 +00:00
|
|
|
IF(NOT MSVC)
|
2019-10-15 21:02:21 +00:00
|
|
|
TARGET_LINK_LIBRARIES(md5_server ${LIBS})
|
|
|
|
TARGET_LINK_LIBRARIES(md5_client ${LIBS})
|
2020-06-03 04:13:30 +00:00
|
|
|
ENDIF()
|
2019-10-15 21:02:21 +00:00
|
|
|
TARGET_LINK_LIBRARIES(echo_server ${LIBS})
|
|
|
|
TARGET_LINK_LIBRARIES(echo_client ${LIBS})
|
2020-09-15 20:42:13 +00:00
|
|
|
TARGET_LINK_LIBRARIES(duck_server ${LIBS})
|
|
|
|
TARGET_LINK_LIBRARIES(duck_client ${LIBS})
|
2017-09-22 21:00:03 +00:00
|
|
|
|
2020-05-17 16:42:32 +00:00
|
|
|
add_subdirectory(bin)
|
|
|
|
ENDIF() # LSQUIC_BIN
|
2017-09-22 21:00:03 +00:00
|
|
|
|
2020-05-16 12:04:38 +00:00
|
|
|
add_subdirectory(src)
|
|
|
|
|
2020-05-17 16:42:32 +00:00
|
|
|
IF(LSQUIC_TESTS AND CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2018-02-28 19:25:21 +00:00
|
|
|
# Our test framework relies on assertions, only compile if assertions are
|
|
|
|
# enabled.
|
|
|
|
#
|
|
|
|
enable_testing()
|
2020-05-17 16:42:32 +00:00
|
|
|
add_subdirectory(tests)
|
2018-02-28 19:25:21 +00:00
|
|
|
ENDIF()
|
|
|
|
|
2020-02-21 19:26:25 +00:00
|
|
|
|
2020-02-20 21:56:57 +00:00
|
|
|
FIND_PROGRAM(SPHINX NAMES sphinx-build)
|
|
|
|
IF(SPHINX)
|
|
|
|
ADD_CUSTOM_TARGET(docs
|
|
|
|
${SPHINX} -b html
|
|
|
|
docs
|
|
|
|
docs/_build
|
|
|
|
)
|
|
|
|
ELSE()
|
|
|
|
MESSAGE(STATUS "sphinx-build not found: docs won't be made")
|
|
|
|
ENDIF()
|
2020-10-01 12:45:41 +00:00
|
|
|
|
|
|
|
INSTALL(FILES
|
|
|
|
include/lsquic.h
|
|
|
|
include/lsquic_types.h
|
|
|
|
include/lsxpack_header.h
|
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lsquic
|
|
|
|
)
|