aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrent Cook <busterb@gmail.com>2018-04-06 04:14:33 -0500
committerBrent Cook <bcook@openbsd.org>2018-04-06 07:43:47 -0500
commit7b33ca2016b5d0459f0ebbcf033c0cc5f9a58224 (patch)
tree5d2cda2c0b81b1942a0c60ba504cb83c2774969c
parent2af9a3bed9db0a8fc791153a77e39acf1e66d2ff (diff)
downloadportable-7b33ca2016b5d0459f0ebbcf033c0cc5f9a58224.tar.gz
portable-7b33ca2016b5d0459f0ebbcf033c0cc5f9a58224.tar.bz2
portable-7b33ca2016b5d0459f0ebbcf033c0cc5f9a58224.zip
better separate linux and non-linux checks for clock_gettime
-rw-r--r--CMakeLists.txt25
1 files 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()
264 264
265set(OPENSSL_LIBS tls ssl crypto) 265set(OPENSSL_LIBS tls ssl crypto)
266 266
267# Add additional required libs
267if(WIN32) 268if(WIN32)
268 set(OPENSSL_LIBS ${OPENSSL_LIBS} ws2_32) 269 set(OPENSSL_LIBS ${OPENSSL_LIBS} ws2_32)
269endif() 270endif()
270
271check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
272if(HAVE_CLOCK_GETTIME)
273 add_definitions(-DHAVE_CLOCK_GETTIME)
274endif()
275
276if(CMAKE_SYSTEM_NAME MATCHES "Linux") 271if(CMAKE_SYSTEM_NAME MATCHES "Linux")
277 set(OPENSSL_LIBS ${OPENSSL_LIBS} pthread) 272 set(OPENSSL_LIBS ${OPENSSL_LIBS} pthread)
278 check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
279 if (HAVE_CLOCK_GETTIME)
280 set(OPENSSL_LIBS ${OPENSSL_LIBS} rt)
281 endif()
282endif() 273endif()
283if(CMAKE_SYSTEM_NAME MATCHES "HP-UX") 274if(CMAKE_SYSTEM_NAME MATCHES "HP-UX")
284 set(OPENSSL_LIBS ${OPENSSL_LIBS} pthread) 275 set(OPENSSL_LIBS ${OPENSSL_LIBS} pthread)
@@ -287,6 +278,20 @@ if(CMAKE_SYSTEM_NAME MATCHES "SunOS")
287 set(OPENSSL_LIBS ${OPENSSL_LIBS} nsl socket) 278 set(OPENSSL_LIBS ${OPENSSL_LIBS} nsl socket)
288endif() 279endif()
289 280
281if(CMAKE_SYSTEM_NAME MATCHES "Linux")
282 # Check if we need -lrt to get clock_gettime on Linux
283 check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
284 if (HAVE_CLOCK_GETTIME)
285 set(OPENSSL_LIBS ${OPENSSL_LIBS} rt)
286 endif()
287else()
288 # Otherwise, simply check if it exists
289 check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
290endif()
291if(HAVE_CLOCK_GETTIME)
292 add_definitions(-DHAVE_CLOCK_GETTIME)
293endif()
294
290check_type_size(time_t SIZEOF_TIME_T) 295check_type_size(time_t SIZEOF_TIME_T)
291if(SIZEOF_TIME_T STREQUAL "4") 296if(SIZEOF_TIME_T STREQUAL "4")
292 set(SMALL_TIME_T true) 297 set(SMALL_TIME_T true)