summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-02-02 18:01:51 -0800
committerEdward Thomson <ethomson@edwardthomson.com>2018-02-02 18:01:51 -0800
commited298c8eac390ddd9c24381e32359f813a996dce (patch)
tree32b5397b27db690e2450318b57ee2ddd80699f1d /cmake
parent6416b91ffeb6863ce331f9370f817b08b260689d (diff)
downloadlibgit2-ed298c8eac390ddd9c24381e32359f813a996dce.tar.gz
cmake: move nanosecond detection to a module
Move the nanosecond detection in time structures to its own module.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Modules/FindStatNsec.cmake20
1 files changed, 20 insertions, 0 deletions
diff --git a/cmake/Modules/FindStatNsec.cmake b/cmake/Modules/FindStatNsec.cmake
new file mode 100644
index 000000000..fa550a214
--- /dev/null
+++ b/cmake/Modules/FindStatNsec.cmake
@@ -0,0 +1,20 @@
+CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtim "sys/types.h;sys/stat.h"
+ HAVE_STRUCT_STAT_ST_MTIM LANGUAGE C)
+CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtimespec "sys/types.h;sys/stat.h"
+ HAVE_STRUCT_STAT_ST_MTIMESPEC LANGUAGE C)
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtime_nsec sys/stat.h
+ HAVE_STRUCT_STAT_MTIME_NSEC LANGUAGE C)
+
+IF (HAVE_STRUCT_STAT_ST_MTIM)
+ CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec sys/stat.h
+ HAVE_STRUCT_STAT_NSEC LANGUAGE C)
+ELSEIF (HAVE_STRUCT_STAT_ST_MTIMESPEC)
+ CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec sys/stat.h
+ HAVE_STRUCT_STAT_NSEC LANGUAGE C)
+ELSE ()
+ SET( HAVE_STRUCT_STAT_NSEC ON )
+ENDIF()
+
+IF (HAVE_STRUCT_STAT_NSEC OR WIN32)
+ OPTION( USE_NSEC "Care about sub-second file mtimes and ctimes" ON )
+ENDIF()