Skip to content

Commit

Permalink
CMake-only computation of whether librt is needed. (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpavlik authored May 6, 2022
1 parent c4854d2 commit d755d26
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
13 changes: 7 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ MESSAGE(STATUS "CMake v${CMAKE_VERSION}")

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()
include(CheckSymbolExists)
check_symbol_exists(clock_getres "time.h" HAS_clock_getres_WITHOUT_LIBRT)

if(NOT HAS_clock_getres_WITHOUT_LIBRT)
find_library(RT_LIBRARY rt)
set(NEED_LIBRT_FOR_clock_getres ON)
endif()
ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "Android")
# for android-ndk >= r19b
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY "BOTH")
Expand Down
13 changes: 0 additions & 13 deletions print-glibc-version.sh

This file was deleted.

4 changes: 4 additions & 0 deletions src/liblsquic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ 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_DEC_LOGGER_HEADER=\\\"lsquic_qpack_dec_logger.h\\\"")

if(NEED_LIBRT_FOR_clock_getres)
target_link_libraries(lsquic PRIVATE ${RT_LIBRARY})
endif()

IF(LSQUIC_SHARED_LIB)
add_library(lsquic SHARED ${lsquic_STAT_SRCS})
TARGET_LINK_LIBRARIES(lsquic PRIVATE ${BORINGSSL_LIB_ssl} ${BORINGSSL_LIB_crypto} ${ZLIB_LIB})
Expand Down

0 comments on commit d755d26

Please sign in to comment.