diff options
| author | Brent Cook <busterb@gmail.com> | 2018-04-06 04:14:33 -0500 |
|---|---|---|
| committer | Brent Cook <busterb@gmail.com> | 2018-04-06 04:21:20 -0500 |
| commit | 0974145a9e62d844b5b159cddbce36552bca30df (patch) | |
| tree | 05c033b4bc21f9b5d0ac6e1713431b6ae70d0122 | |
| parent | d34dcede691a700a301d9b86929f6d7da157fef3 (diff) | |
| download | portable-0974145a9e62d844b5b159cddbce36552bca30df.tar.gz portable-0974145a9e62d844b5b159cddbce36552bca30df.tar.bz2 portable-0974145a9e62d844b5b159cddbce36552bca30df.zip | |
better separate linux and non-linux checks for clock_gettime
| -rw-r--r-- | CMakeLists.txt | 25 |
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 | ||
| 265 | set(OPENSSL_LIBS tls ssl crypto) | 265 | set(OPENSSL_LIBS tls ssl crypto) |
| 266 | 266 | ||
| 267 | # Add additional required libs | ||
| 267 | if(WIN32) | 268 | if(WIN32) |
| 268 | set(OPENSSL_LIBS ${OPENSSL_LIBS} ws2_32) | 269 | set(OPENSSL_LIBS ${OPENSSL_LIBS} ws2_32) |
| 269 | endif() | 270 | endif() |
| 270 | |||
| 271 | check_function_exists(clock_gettime HAVE_CLOCK_GETTIME) | ||
| 272 | if(HAVE_CLOCK_GETTIME) | ||
| 273 | add_definitions(-DHAVE_CLOCK_GETTIME) | ||
| 274 | endif() | ||
| 275 | |||
| 276 | if(CMAKE_SYSTEM_NAME MATCHES "Linux") | 271 | if(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() | ||
| 282 | endif() | 273 | endif() |
| 283 | if(CMAKE_SYSTEM_NAME MATCHES "HP-UX") | 274 | if(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) |
| 288 | endif() | 279 | endif() |
| 289 | 280 | ||
| 281 | if(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() | ||
| 287 | else() | ||
| 288 | # Otherwise, simply check if it exists | ||
| 289 | check_function_exists(clock_gettime HAVE_CLOCK_GETTIME) | ||
| 290 | endif() | ||
| 291 | if(HAVE_CLOCK_GETTIME) | ||
| 292 | add_definitions(-DHAVE_CLOCK_GETTIME) | ||
| 293 | endif() | ||
| 294 | |||
| 290 | check_type_size(time_t SIZEOF_TIME_T) | 295 | check_type_size(time_t SIZEOF_TIME_T) |
| 291 | if(SIZEOF_TIME_T STREQUAL "4") | 296 | if(SIZEOF_TIME_T STREQUAL "4") |
| 292 | set(SMALL_TIME_T true) | 297 | set(SMALL_TIME_T true) |
