aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2023-09-23 03:06:36 +0300
committerLasse Collin <lasse.collin@tukaani.org>2023-10-22 18:59:45 +0300
commit680e52cdd086e92691d8a0bca2c98815565f60ca (patch)
tree4e3b0fb5410f6dcebfc007b2cace93b04c5c3a5d
parentBuild: Check for clock_gettime() even if not using POSIX threads. (diff)
downloadxz-680e52cdd086e92691d8a0bca2c98815565f60ca.tar.xz
CMake: Check for clock_gettime() even on Windows.
This mirrors configure.ac although currently MinGW-w64 builds don't use clock_gettime() even if it is found.
Diffstat (limited to '')
-rw-r--r--CMakeLists.txt44
1 files changed, 21 insertions, 23 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 128e4a47..2d3dabec 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -151,32 +151,30 @@ tuklib_integer(ALL)
# Check for clock_gettime(). Do this before checking for threading so
# that we know there if CLOCK_MONOTONIC is available.
-if(NOT WIN32)
- check_symbol_exists(clock_gettime time.h HAVE_CLOCK_GETTIME)
-
- if(NOT HAVE_CLOCK_GETTIME)
- # With glibc <= 2.17 or Solaris 10 this needs librt.
- # Add librt for the next check for HAVE_CLOCK_GETTIME. If it is
- # found after including the library, we know that librt is required.
- list(INSERT CMAKE_REQUIRED_LIBRARIES 0 rt)
- check_symbol_exists(clock_gettime time.h HAVE_CLOCK_GETTIME_LIBRT)
-
- # If it was found now, add librt to all targets and keep it in
- # CMAKE_REQUIRED_LIBRARIES for further tests too.
- if(HAVE_CLOCK_GETTIME_LIBRT)
- link_libraries(rt)
- else()
- list(REMOVE_AT CMAKE_REQUIRED_LIBRARIES 0)
- endif()
+check_symbol_exists(clock_gettime time.h HAVE_CLOCK_GETTIME)
+
+if(NOT HAVE_CLOCK_GETTIME)
+ # With glibc <= 2.17 or Solaris 10 this needs librt.
+ # Add librt for the next check for HAVE_CLOCK_GETTIME. If it is
+ # found after including the library, we know that librt is required.
+ list(INSERT CMAKE_REQUIRED_LIBRARIES 0 rt)
+ check_symbol_exists(clock_gettime time.h HAVE_CLOCK_GETTIME_LIBRT)
+
+ # If it was found now, add librt to all targets and keep it in
+ # CMAKE_REQUIRED_LIBRARIES for further tests too.
+ if(HAVE_CLOCK_GETTIME_LIBRT)
+ link_libraries(rt)
+ else()
+ list(REMOVE_AT CMAKE_REQUIRED_LIBRARIES 0)
endif()
+endif()
- if(HAVE_CLOCK_GETTIME OR HAVE_CLOCK_GETTIME_LIBRT)
- add_compile_definitions(HAVE_CLOCK_GETTIME)
+if(HAVE_CLOCK_GETTIME OR HAVE_CLOCK_GETTIME_LIBRT)
+ add_compile_definitions(HAVE_CLOCK_GETTIME)
- # Check if CLOCK_MONOTONIC is available for clock_gettime().
- check_symbol_exists(CLOCK_MONOTONIC time.h HAVE_CLOCK_MONOTONIC)
- tuklib_add_definition_if(ALL HAVE_CLOCK_MONOTONIC)
- endif()
+ # Check if CLOCK_MONOTONIC is available for clock_gettime().
+ check_symbol_exists(CLOCK_MONOTONIC time.h HAVE_CLOCK_MONOTONIC)
+ tuklib_add_definition_if(ALL HAVE_CLOCK_MONOTONIC)
endif()
# Options for new enough GCC or Clang on any arch or operating system: