mirror of
https://gitea.invidious.io/iv-org/litespeed-quic.git
synced 2024-08-15 00:53:43 +00:00
Simplify configuration -- use more cmake functions (#62)
This commit is contained in:
parent
93b02ebee8
commit
b1af35d6c0
4 changed files with 85 additions and 46 deletions
|
@ -11,10 +11,8 @@ task:
|
|||
- git checkout 32e59d2d3264e4e104b355ef73663b8b79ac4093
|
||||
- cmake .
|
||||
- make
|
||||
- ln -s ssl/libssl.a
|
||||
- ln -s crypto/libcrypto.a
|
||||
- cd -
|
||||
script:
|
||||
- cmake -DBORINGSSL_INCLUDE=$PWD/boringssl/include -DBORINGSSL_LIB=$PWD/boringssl .
|
||||
- cmake -DBORINGSSL_DIR=$PWD/boringssl .
|
||||
- make
|
||||
- make test
|
||||
|
|
|
@ -26,10 +26,8 @@ before_script:
|
|||
- git checkout 32e59d2d3264e4e104b355ef73663b8b79ac4093
|
||||
- cmake .
|
||||
- make
|
||||
- ln -s ssl/libssl.a
|
||||
- ln -s crypto/libcrypto.a
|
||||
- cd -
|
||||
- cmake -DBORINGSSL_INCLUDE=$PWD/boringssl/include -DBORINGSSL_LIB=$PWD/boringssl .
|
||||
- cmake -DBORINGSSL_DIR=$PWD/boringssl .
|
||||
script:
|
||||
# Now build lsquic-client
|
||||
- make
|
||||
|
|
111
CMakeLists.txt
111
CMakeLists.txt
|
@ -2,20 +2,7 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
|
||||
project(lsquic)
|
||||
|
||||
IF (NOT MSVC)
|
||||
# We prefer clang
|
||||
IF(NOT ("${CMAKE_C_COMPILER}" MATCHES "ccc-analyzer" OR
|
||||
"${CMAKE_C_COMPILER}" MATCHES "gcc" OR
|
||||
"${CMAKE_C_COMPILER}" MATCHES "afl-gcc"))
|
||||
FIND_PROGRAM(CLANG "clang")
|
||||
IF(CLANG)
|
||||
SET(CMAKE_C_COMPILER "${CLANG}")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
ENDIF()
|
||||
PROJECT(lsquic C)
|
||||
|
||||
IF (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
# If using older glibc, need to link with -lrt. See clock_getres(2).
|
||||
|
@ -94,25 +81,84 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_CMAKE_FLAGS} $ENV{EXTRA_CFLAGS}")
|
|||
|
||||
MESSAGE(STATUS "Compiler flags: ${CMAKE_C_FLAGS}")
|
||||
|
||||
IF(NOT DEFINED BORINGSSL_INCLUDE)
|
||||
SET(BORINGSSL_INCLUDE /usr/local/include)
|
||||
ENDIF()
|
||||
IF(NOT DEFINED BORINGSSL_LIB)
|
||||
SET(BORINGSSL_LIB /usr/local/lib)
|
||||
# This must be done before adding other include directories to take
|
||||
# precedence over header files from other SSL installs.
|
||||
FIND_PATH(BORINGSSL_INCLUDE_DIR NAMES openssl/ssl.h
|
||||
PATHS ${BORINGSSL_DIR}/include
|
||||
NO_DEFAULT_PATH)
|
||||
IF (BORINGSSL_INCLUDE_DIR)
|
||||
MESSAGE(STATUS "BoringSSL include directory ${BORINGSSL_INCLUDE_DIR}")
|
||||
INCLUDE_DIRECTORIES(${BORINGSSL_INCLUDE_DIR})
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "BoringSSL headers not found")
|
||||
ENDIF()
|
||||
|
||||
FOREACH(BORINGSSL_LIB ssl crypto decrepit)
|
||||
IF (CMAKE_SYSTEM_NAME STREQUAL Windows)
|
||||
FIND_LIBRARY(BORINGSSL_LIB_${BORINGSSL_LIB}
|
||||
NAMES ${BORINGSSL_LIB}
|
||||
PATHS ${BORINGSSL_DIR}/${BORINGSSL_LIB}
|
||||
PATH_SUFFIXES Debug Release MinSizeRel RelWithDebInfo
|
||||
NO_DEFAULT_PATH)
|
||||
ELSE()
|
||||
FIND_LIBRARY(BORINGSSL_LIB_${BORINGSSL_LIB}
|
||||
NAMES lib${BORINGSSL_LIB}.a
|
||||
PATHS ${BORINGSSL_DIR}/${BORINGSSL_LIB}
|
||||
NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(BORINGSSL_LIB_${BORINGSSL_LIB})
|
||||
MESSAGE(STATUS "Found ${BORINGSSL_LIB} library: ${BORINGSSL_LIB_${BORINGSSL_LIB}}")
|
||||
ELSE()
|
||||
MESSAGE(STATUS "${BORINGSSL_LIB} library not found")
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
|
||||
include_directories(${BORINGSSL_INCLUDE} ${VCPKG_INCLUDE})
|
||||
link_directories( ${BORINGSSL_LIB} )
|
||||
IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
# Find libevent on FreeBSD:
|
||||
INCLUDE_DIRECTORIES( /usr/local/include )
|
||||
LINK_DIRECTORIES( /usr/local/lib )
|
||||
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()
|
||||
FIND_LIBRARY(ZLIB_LIB libz.a)
|
||||
ENDIF()
|
||||
IF(ZLIB_LIB)
|
||||
MESSAGE(STATUS "Found zlib: ${ZLIB_LIB}")
|
||||
ELSE()
|
||||
MESSAGE(STATUS "zlib not found")
|
||||
ENDIF()
|
||||
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()
|
||||
FIND_LIBRARY(EVENT_LIB libevent.a)
|
||||
ENDIF()
|
||||
IF(EVENT_LIB)
|
||||
MESSAGE(STATUS "Found event: ${EVENT_LIB}")
|
||||
ELSE()
|
||||
MESSAGE(STATUS "libevent not found")
|
||||
ENDIF()
|
||||
|
||||
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
include_directories( include src/lshpack)
|
||||
IF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
# Find libevent on FreeBSD:
|
||||
include_directories( /usr/local/include )
|
||||
link_directories( /usr/local/lib )
|
||||
ENDIF()
|
||||
|
||||
|
||||
IF (NOT MSVC)
|
||||
add_executable(http_client
|
||||
|
@ -120,7 +166,8 @@ add_executable(http_client
|
|||
test/prog.c
|
||||
test/test_common.c
|
||||
)
|
||||
target_link_libraries(http_client lsquic event pthread libssl.a libcrypto.a ${LIBS} z m)
|
||||
TARGET_LINK_LIBRARIES(http_client lsquic ${EVENT_LIB} pthread
|
||||
${BORINGSSL_LIB_ssl} ${BORINGSSL_LIB_crypto} ${LIBS} ${ZLIB_LIB} m)
|
||||
|
||||
#MSVC
|
||||
ELSE()
|
||||
|
@ -134,10 +181,10 @@ add_executable(http_client
|
|||
|
||||
target_link_libraries(http_client
|
||||
lsquic
|
||||
${VCPKG_LIB}/event.lib
|
||||
${VCPKG_LIB}/zlib.lib
|
||||
${BORINGSSL_LIB}/ssl.lib
|
||||
${BORINGSSL_LIB}/crypto.lib
|
||||
${EVENT_LIB}
|
||||
${ZLIB_LIB}
|
||||
${BORINGSSL_LIB_ssl}
|
||||
${BORINGSSL_LIB_crypto}
|
||||
ws2_32
|
||||
${LIBS} )
|
||||
|
||||
|
|
|
@ -4,19 +4,15 @@ INCLUDE_DIRECTORIES(../../src/liblsquic)
|
|||
|
||||
ENABLE_TESTING()
|
||||
|
||||
SET(LIBS lsquic ${BORINGSSL_LIB_crypto} ${BORINGSSL_LIB_ssl} ${ZLIB_LIB})
|
||||
|
||||
IF (MSVC)
|
||||
SET(LIBS
|
||||
lsquic
|
||||
${VCPKG_LIB}/event.lib
|
||||
${VCPKG_LIB}/zlib.lib
|
||||
${BORINGSSL_LIB}/ssl.lib
|
||||
${BORINGSSL_LIB}/crypto.lib
|
||||
ws2_32)
|
||||
LIST(APPEND LIBS ws2_32)
|
||||
SET(ADDL_SOURCES ../../wincompat/getopt.c ../../wincompat/getopt1.c)
|
||||
SET(LIB_FLAGS "-FORCE:MULTIPLE")
|
||||
ELSE()
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-value")
|
||||
SET(LIBS lsquic libcrypto.a libssl.a z m pthread)
|
||||
LIST(APPEND LIBS m pthread)
|
||||
ENDIF()
|
||||
|
||||
SET(TESTS
|
||||
|
|
Loading…
Reference in a new issue