FindStatNsec.cmake 921 Bytes
Newer Older
1 2
INCLUDE(FeatureSummary)

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
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  )
22 23
ELSE()
	SET(USE_NSEC OFF)
24
ENDIF()
25 26

ADD_FEATURE_INFO(nanoseconds USE_NSEC "whether to use sub-second file mtimes and ctimes")