Look for .so BoringSSL libs if LSQUIC_SHARED_LIB option is on

This commit is contained in:
Dmitri Tikhonov 2020-09-25 14:09:10 -04:00
parent 038a944155
commit 2e1429b465
3 changed files with 14 additions and 7 deletions

View file

@ -7,6 +7,7 @@ PROJECT(lsquic C)
OPTION(LSQUIC_FIU "Use Fault Injection in Userspace (FIU)" OFF) OPTION(LSQUIC_FIU "Use Fault Injection in Userspace (FIU)" OFF)
OPTION(LSQUIC_BIN "Compile example binaries that use the library" ON) OPTION(LSQUIC_BIN "Compile example binaries that use the library" ON)
OPTION(LSQUIC_TESTS "Compile library unit tests" ON) OPTION(LSQUIC_TESTS "Compile library unit tests" ON)
OPTION(LSQUIC_SHARED_LIB "Compile as shared librarry" OFF)
IF (CMAKE_SYSTEM_NAME STREQUAL "Linux") IF (CMAKE_SYSTEM_NAME STREQUAL "Linux")
# If using older glibc, need to link with -lrt. See clock_getres(2). # If using older glibc, need to link with -lrt. See clock_getres(2).
@ -122,6 +123,12 @@ IF(NOT PERL_FOUND)
MESSAGE(FATAL_ERROR "Perl not found -- need it to generate source code") MESSAGE(FATAL_ERROR "Perl not found -- need it to generate source code")
ENDIF() ENDIF()
IF(LSQUIC_SHARED_LIB)
SET(LIB_SUFFIX .so)
ELSE()
SET(LIB_SUFFIX .a)
ENDIF()
IF (NOT DEFINED BORINGSSL_INCLUDE AND DEFINED BORINGSSL_DIR) IF (NOT DEFINED BORINGSSL_INCLUDE AND DEFINED BORINGSSL_DIR)
FIND_PATH(BORINGSSL_INCLUDE NAMES openssl/ssl.h FIND_PATH(BORINGSSL_INCLUDE NAMES openssl/ssl.h
PATHS ${BORINGSSL_DIR}/include PATHS ${BORINGSSL_DIR}/include
@ -147,7 +154,7 @@ IF (NOT DEFINED BORINGSSL_LIB AND DEFINED BORINGSSL_DIR)
NO_DEFAULT_PATH) NO_DEFAULT_PATH)
ELSE() ELSE()
FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME}
NAMES lib${LIB_NAME}.a NAMES lib${LIB_NAME}${LIB_SUFFIX}
PATHS ${BORINGSSL_DIR}/${LIB_NAME} PATHS ${BORINGSSL_DIR}/${LIB_NAME}
NO_DEFAULT_PATH) NO_DEFAULT_PATH)
ENDIF() ENDIF()
@ -170,7 +177,7 @@ ELSE()
NO_DEFAULT_PATH) NO_DEFAULT_PATH)
ELSE() ELSE()
FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME}
NAMES lib${LIB_NAME}.a NAMES lib${LIB_NAME}${LIB_SUFFIX}
PATHS ${BORINGSSL_LIB} PATHS ${BORINGSSL_LIB}
PATH_SUFFIXES ${LIB_NAME} PATH_SUFFIXES ${LIB_NAME}
NO_DEFAULT_PATH) NO_DEFAULT_PATH)
@ -206,7 +213,7 @@ ELSEIF(CMAKE_SYSTEM_NAME STREQUAL Darwin)
# XXX somehow FIND_LIBRARY() does not find zlib on Travis? # XXX somehow FIND_LIBRARY() does not find zlib on Travis?
SET(ZLIB_LIB z) SET(ZLIB_LIB z)
ELSE() ELSE()
FIND_LIBRARY(ZLIB_LIB libz.a) FIND_LIBRARY(ZLIB_LIB libz${LIB_SUFFIX})
ENDIF() ENDIF()
IF(ZLIB_LIB) IF(ZLIB_LIB)
MESSAGE(STATUS "Found zlib: ${ZLIB_LIB}") MESSAGE(STATUS "Found zlib: ${ZLIB_LIB}")
@ -224,7 +231,7 @@ ENDIF()
IF (CMAKE_SYSTEM_NAME STREQUAL Windows) IF (CMAKE_SYSTEM_NAME STREQUAL Windows)
FIND_LIBRARY(EVENT_LIB event) FIND_LIBRARY(EVENT_LIB event)
ELSE() ELSE()
FIND_LIBRARY(EVENT_LIB libevent.a) FIND_LIBRARY(EVENT_LIB libevent${LIB_SUFFIX})
IF(NOT EVENT_LIB) IF(NOT EVENT_LIB)
FIND_LIBRARY(EVENT_LIB libevent.so) FIND_LIBRARY(EVENT_LIB libevent.so)
ENDIF() ENDIF()

View file

@ -108,7 +108,7 @@ make
As a dynamic library: As a dynamic library:
``` ```
cmake -DAS_SHARED_LIB=true . cmake -DLSQUIC_SHARED_LIB=1 -DBORINGSSL_DIR=$BORINGSSL .
make make
``` ```

View file

@ -109,9 +109,9 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXXH_HEADER_NAME=\\\"lsquic_xxhash.h\\\"")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLSQPACK_ENC_LOGGER_HEADER=\\\"lsquic_qpack_enc_logger.h\\\"") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLSQPACK_ENC_LOGGER_HEADER=\\\"lsquic_qpack_enc_logger.h\\\"")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLSQPACK_DEC_LOGGER_HEADER=\\\"lsquic_qpack_dec_logger.h\\\"") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLSQPACK_DEC_LOGGER_HEADER=\\\"lsquic_qpack_dec_logger.h\\\"")
IF(DEFINED AS_SHARED_LIB) IF(LSQUIC_SHARED_LIB)
add_library(lsquic SHARED ${lsquic_STAT_SRCS} ) add_library(lsquic SHARED ${lsquic_STAT_SRCS} )
TARGET_LINK_LIBRARIES(lsquic PRIVATE ${BORINGSSL_LIB_ssl} ${BORINGSSL_LIB_crypto} /usr/lib/libz.so) TARGET_LINK_LIBRARIES(lsquic PRIVATE ${BORINGSSL_LIB_ssl} ${BORINGSSL_LIB_crypto} ${ZLIB_LIB})
ELSE() ELSE()
add_library(lsquic STATIC ${lsquic_STAT_SRCS}) add_library(lsquic STATIC ${lsquic_STAT_SRCS})
ENDIF() ENDIF()