Skip to content

Commit

Permalink
better separate linux and non-linux checks for clock_gettime
Browse files Browse the repository at this point in the history
  • Loading branch information
busterb committed Apr 6, 2018
1 parent d34dced commit 0974145
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 0974145

Please sign in to comment.