Skip to content

Commit ed298c8

Browse files
committed
cmake: move nanosecond detection to a module
Move the nanosecond detection in time structures to its own module.
1 parent 6416b91 commit ed298c8

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

CMakeLists.txt

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ INCLUDE(CheckStructHasMember)
3131
INCLUDE(AddCFlagIfSupported)
3232
INCLUDE(FindPkgConfig)
3333
INCLUDE(FindThreads)
34+
INCLUDE(FindStatNsec)
3435
INCLUDE(FeatureSummary)
3536

3637
# Build options
@@ -94,27 +95,6 @@ IF(MSVC)
9495
OPTION(MSVC_CRTDBG "Enable CRTDBG memory leak reporting" OFF)
9596
ENDIF()
9697

97-
CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtim "sys/types.h;sys/stat.h"
98-
HAVE_STRUCT_STAT_ST_MTIM LANGUAGE C)
99-
CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtimespec "sys/types.h;sys/stat.h"
100-
HAVE_STRUCT_STAT_ST_MTIMESPEC LANGUAGE C)
101-
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtime_nsec sys/stat.h
102-
HAVE_STRUCT_STAT_MTIME_NSEC LANGUAGE C)
103-
104-
IF (HAVE_STRUCT_STAT_ST_MTIM)
105-
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec sys/stat.h
106-
HAVE_STRUCT_STAT_NSEC LANGUAGE C)
107-
ELSEIF (HAVE_STRUCT_STAT_ST_MTIMESPEC)
108-
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec sys/stat.h
109-
HAVE_STRUCT_STAT_NSEC LANGUAGE C)
110-
ELSE ()
111-
SET( HAVE_STRUCT_STAT_NSEC ON )
112-
ENDIF()
113-
114-
IF (HAVE_STRUCT_STAT_NSEC OR WIN32)
115-
OPTION( USE_NSEC "Care about sub-second file mtimes and ctimes" ON )
116-
ENDIF()
117-
11898
# This function splits the sources files up into their appropriate
11999
# subdirectories. This is especially useful for IDEs like Xcode and
120100
# Visual Studio, so that you can navigate into the libgit2_clar project,

cmake/Modules/FindStatNsec.cmake

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtim "sys/types.h;sys/stat.h"
2+
HAVE_STRUCT_STAT_ST_MTIM LANGUAGE C)
3+
CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtimespec "sys/types.h;sys/stat.h"
4+
HAVE_STRUCT_STAT_ST_MTIMESPEC LANGUAGE C)
5+
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtime_nsec sys/stat.h
6+
HAVE_STRUCT_STAT_MTIME_NSEC LANGUAGE C)
7+
8+
IF (HAVE_STRUCT_STAT_ST_MTIM)
9+
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec sys/stat.h
10+
HAVE_STRUCT_STAT_NSEC LANGUAGE C)
11+
ELSEIF (HAVE_STRUCT_STAT_ST_MTIMESPEC)
12+
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec sys/stat.h
13+
HAVE_STRUCT_STAT_NSEC LANGUAGE C)
14+
ELSE ()
15+
SET( HAVE_STRUCT_STAT_NSEC ON )
16+
ENDIF()
17+
18+
IF (HAVE_STRUCT_STAT_NSEC OR WIN32)
19+
OPTION( USE_NSEC "Care about sub-second file mtimes and ctimes" ON )
20+
ENDIF()

0 commit comments

Comments
 (0)