better separate linux and non-linux checks for clock_gettime

This commit is contained in:
Brent Cook 2018-04-06 04:14:33 -05:00
parent d34dcede69
commit 0974145a9e

View File

@ -264,21 +264,12 @@ endif()
set(OPENSSL_LIBS tls ssl crypto) set(OPENSSL_LIBS tls ssl crypto)
# Add additional required libs
if(WIN32) if(WIN32)
set(OPENSSL_LIBS ${OPENSSL_LIBS} ws2_32) set(OPENSSL_LIBS ${OPENSSL_LIBS} ws2_32)
endif() endif()
check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
if(HAVE_CLOCK_GETTIME)
add_definitions(-DHAVE_CLOCK_GETTIME)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux") if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(OPENSSL_LIBS ${OPENSSL_LIBS} pthread) set(OPENSSL_LIBS ${OPENSSL_LIBS} pthread)
check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
if (HAVE_CLOCK_GETTIME)
set(OPENSSL_LIBS ${OPENSSL_LIBS} rt)
endif()
endif() endif()
if(CMAKE_SYSTEM_NAME MATCHES "HP-UX") if(CMAKE_SYSTEM_NAME MATCHES "HP-UX")
set(OPENSSL_LIBS ${OPENSSL_LIBS} pthread) set(OPENSSL_LIBS ${OPENSSL_LIBS} pthread)
@ -287,6 +278,20 @@ if(CMAKE_SYSTEM_NAME MATCHES "SunOS")
set(OPENSSL_LIBS ${OPENSSL_LIBS} nsl socket) set(OPENSSL_LIBS ${OPENSSL_LIBS} nsl socket)
endif() endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
# Check if we need -lrt to get clock_gettime on Linux
check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
if (HAVE_CLOCK_GETTIME)
set(OPENSSL_LIBS ${OPENSSL_LIBS} rt)
endif()
else()
# Otherwise, simply check if it exists
check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
endif()
if(HAVE_CLOCK_GETTIME)
add_definitions(-DHAVE_CLOCK_GETTIME)
endif()
check_type_size(time_t SIZEOF_TIME_T) check_type_size(time_t SIZEOF_TIME_T)
if(SIZEOF_TIME_T STREQUAL "4") if(SIZEOF_TIME_T STREQUAL "4")
set(SMALL_TIME_T true) set(SMALL_TIME_T true)