From 7b33ca2016b5d0459f0ebbcf033c0cc5f9a58224 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Fri, 6 Apr 2018 04:14:33 -0500 Subject: better separate linux and non-linux checks for clock_gettime --- CMakeLists.txt | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b20778..549849f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -264,21 +264,12 @@ endif() set(OPENSSL_LIBS tls ssl crypto) +# Add additional required libs if(WIN32) set(OPENSSL_LIBS ${OPENSSL_LIBS} ws2_32) 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") 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() if(CMAKE_SYSTEM_NAME MATCHES "HP-UX") set(OPENSSL_LIBS ${OPENSSL_LIBS} pthread) @@ -287,6 +278,20 @@ if(CMAKE_SYSTEM_NAME MATCHES "SunOS") set(OPENSSL_LIBS ${OPENSSL_LIBS} nsl socket) 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) if(SIZEOF_TIME_T STREQUAL "4") set(SMALL_TIME_T true) -- cgit v1.2.3-55-g6feb