Commit e9e6df2c by Axel Rasmussen

cmake: Only provide USE_NSEC if struct stat members are avilable.

This allows us to remove OS checks from source code, instead relying
on CMake to detect whether or not `struct stat` has the nanoseconds
members we rely on.
parent 2be78557
......@@ -19,9 +19,13 @@ CMAKE_POLICY(SET CMP0015 NEW)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
INCLUDE(CheckLibraryExists)
INCLUDE(CheckStructHasMember)
INCLUDE(AddCFlagIfSupported)
INCLUDE(FindPkgConfig)
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec sys/stat.h
HAVE_STRUCT_STAT_NSEC LANGUAGE C)
# Build options
#
OPTION( SONAME "Set the (SO)VERSION of the target" ON )
......@@ -37,7 +41,9 @@ OPTION( LIBGIT2_FILENAME "Name of the produced binary" OFF )
OPTION( USE_ICONV "Link with and use iconv library" OFF )
OPTION( USE_SSH "Link with libssh to enable SSH support" ON )
OPTION( USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF )
OPTION( USE_NSEC "Care about sub-second file mtimes and ctimes" OFF )
IF(HAVE_STRUCT_STAT_NSEC)
OPTION( USE_NSEC "Care about sub-second file mtimes and ctimes" OFF )
ENDIF()
OPTION( VALGRIND "Configure build for valgrind" OFF )
OPTION( CURL "User curl for HTTP if available" ON)
......
......@@ -858,8 +858,7 @@ void git_index_entry__init_from_stat(
{
entry->ctime.seconds = (git_time_t)st->st_ctime;
entry->mtime.seconds = (git_time_t)st->st_mtime;
#if !defined(GIT_WIN32) && !defined(__APPLE__)
/* Apple and Windows doesn't provide these struct stat fields. */
#if defined(GIT_USE_NSEC)
entry->mtime.nanoseconds = st->st_mtim.tv_nsec;
entry->ctime.nanoseconds = st->st_ctim.tv_nsec;
#endif
......
......@@ -164,8 +164,7 @@ static void hack_index(char *files[])
entry->ctime.seconds = (git_time_t)statbuf.st_ctime;
entry->mtime.seconds = (git_time_t)statbuf.st_mtime;
#if !defined(GIT_WIN32) && !defined(__APPLE__)
/* Apple and Windows doesn't provide these struct stat fields. */
#if defined(GIT_USE_NSEC)
entry->ctime.nanoseconds = statbuf.st_ctim.tv_nsec;
entry->mtime.nanoseconds = statbuf.st_mtim.tv_nsec;
#else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment