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.
This commit is contained in:
Lasse Collin 2023-09-23 03:06:36 +03:00
parent 1c1a8c3ee4
commit 680e52cdd0
1 changed files with 19 additions and 21 deletions

View File

@ -151,10 +151,9 @@ tuklib_integer(ALL)
# Check for clock_gettime(). Do this before checking for threading so # Check for clock_gettime(). Do this before checking for threading so
# that we know there if CLOCK_MONOTONIC is available. # that we know there if CLOCK_MONOTONIC is available.
if(NOT WIN32) check_symbol_exists(clock_gettime time.h HAVE_CLOCK_GETTIME)
check_symbol_exists(clock_gettime time.h HAVE_CLOCK_GETTIME)
if(NOT HAVE_CLOCK_GETTIME) if(NOT HAVE_CLOCK_GETTIME)
# With glibc <= 2.17 or Solaris 10 this needs librt. # With glibc <= 2.17 or Solaris 10 this needs librt.
# Add librt for the next check for HAVE_CLOCK_GETTIME. If it is # Add librt for the next check for HAVE_CLOCK_GETTIME. If it is
# found after including the library, we know that librt is required. # found after including the library, we know that librt is required.
@ -168,15 +167,14 @@ if(NOT WIN32)
else() else()
list(REMOVE_AT CMAKE_REQUIRED_LIBRARIES 0) list(REMOVE_AT CMAKE_REQUIRED_LIBRARIES 0)
endif() endif()
endif() endif()
if(HAVE_CLOCK_GETTIME OR HAVE_CLOCK_GETTIME_LIBRT) if(HAVE_CLOCK_GETTIME OR HAVE_CLOCK_GETTIME_LIBRT)
add_compile_definitions(HAVE_CLOCK_GETTIME) add_compile_definitions(HAVE_CLOCK_GETTIME)
# Check if CLOCK_MONOTONIC is available for clock_gettime(). # Check if CLOCK_MONOTONIC is available for clock_gettime().
check_symbol_exists(CLOCK_MONOTONIC time.h HAVE_CLOCK_MONOTONIC) check_symbol_exists(CLOCK_MONOTONIC time.h HAVE_CLOCK_MONOTONIC)
tuklib_add_definition_if(ALL HAVE_CLOCK_MONOTONIC) tuklib_add_definition_if(ALL HAVE_CLOCK_MONOTONIC)
endif()
endif() endif()
# Options for new enough GCC or Clang on any arch or operating system: # Options for new enough GCC or Clang on any arch or operating system: