mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
For consistency, specify the nanosecond option in the same way as other options, and identify it as such. Split the detection of platform support (`FindStatNsec`) and its selection (`SelectNsec`).
59 lines
2.1 KiB
CMake
59 lines
2.1 KiB
CMake
include(SanitizeBool)
|
|
include(FeatureSummary)
|
|
|
|
sanitizebool(USE_NSEC)
|
|
|
|
if((USE_NSEC STREQUAL ON OR USE_NSEC STREQUAL "") AND HAVE_STRUCT_STAT_ST_MTIM)
|
|
set(USE_NSEC "mtim")
|
|
elseif((USE_NSEC STREQUAL ON OR USE_NSEC STREQUAL "") AND HAVE_STRUCT_STAT_ST_MTIMESPEC)
|
|
set(USE_NSEC "mtimespec")
|
|
elseif((USE_NSEC STREQUAL ON OR USE_NSEC STREQUAL "") AND HAVE_STRUCT_STAT_MTIME_NSEC)
|
|
set(USE_NSEC "mtime_nsec")
|
|
elseif((USE_NSEC STREQUAL ON OR USE_NSEC STREQUAL "") AND WIN32)
|
|
set(USE_NSEC "win32")
|
|
elseif(USE_NSEC STREQUAL "")
|
|
message(WARNING "nanosecond timestamp precision was not detected")
|
|
set(USE_NSEC OFF)
|
|
elseif(USE_NSEC STREQUAL ON)
|
|
message(FATAL_ERROR "nanosecond support was requested but no platform support is available")
|
|
endif()
|
|
|
|
if(USE_NSEC STREQUAL "mtim")
|
|
if(NOT HAVE_STRUCT_STAT_ST_MTIM)
|
|
message(FATAL_ERROR "stat mtim could not be found")
|
|
endif()
|
|
|
|
set(GIT_NSEC 1)
|
|
set(GIT_NSEC_MTIM 1)
|
|
add_feature_info("Nanosecond support" ON "using mtim")
|
|
elseif(USE_NSEC STREQUAL "mtimespec")
|
|
if(NOT HAVE_STRUCT_STAT_ST_MTIMESPEC)
|
|
message(FATAL_ERROR "mtimespec could not be found")
|
|
endif()
|
|
|
|
set(GIT_NSEC 1)
|
|
set(GIT_NSEC_MTIMESPEC 1)
|
|
add_feature_info("Nanosecond support" ON "using mtimespec")
|
|
elseif(USE_NSEC STREQUAL "mtime_nsec")
|
|
if(NOT HAVE_STRUCT_STAT_MTIME_NSEC)
|
|
message(FATAL_ERROR "mtime_nsec could not be found")
|
|
endif()
|
|
|
|
set(GIT_NSEC 1)
|
|
set(GIT_NSEC_MTIME_NSEC 1)
|
|
add_feature_info("Nanosecond support" ON "using mtime_nsec")
|
|
elseif(USE_NSEC STREQUAL "win32")
|
|
if(NOT WIN32)
|
|
message(FATAL_ERROR "Win32 API support is not available on this platform")
|
|
endif()
|
|
|
|
set(GIT_NSEC 1)
|
|
set(GIT_NSEC_WIN32 1)
|
|
add_feature_info("Nanosecond support" ON "using Win32 APIs")
|
|
elseif(USE_NSEC STREQUAL OFF)
|
|
set(GIT_NSEC 0)
|
|
add_feature_info("Nanosecond support" OFF "Nanosecond timestamp resolution is disabled")
|
|
else()
|
|
message(FATAL_ERROR "unknown nanosecond option: ${USE_NSEC}")
|
|
endif()
|