mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-05 13:48:41 +00:00
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.
This commit is contained in:
parent
2be7855727
commit
e9e6df2c8f
@ -19,9 +19,13 @@ CMAKE_POLICY(SET CMP0015 NEW)
|
|||||||
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
|
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
|
||||||
|
|
||||||
INCLUDE(CheckLibraryExists)
|
INCLUDE(CheckLibraryExists)
|
||||||
|
INCLUDE(CheckStructHasMember)
|
||||||
INCLUDE(AddCFlagIfSupported)
|
INCLUDE(AddCFlagIfSupported)
|
||||||
INCLUDE(FindPkgConfig)
|
INCLUDE(FindPkgConfig)
|
||||||
|
|
||||||
|
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec sys/stat.h
|
||||||
|
HAVE_STRUCT_STAT_NSEC LANGUAGE C)
|
||||||
|
|
||||||
# Build options
|
# Build options
|
||||||
#
|
#
|
||||||
OPTION( SONAME "Set the (SO)VERSION of the target" ON )
|
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_ICONV "Link with and use iconv library" OFF )
|
||||||
OPTION( USE_SSH "Link with libssh to enable SSH support" ON )
|
OPTION( USE_SSH "Link with libssh to enable SSH support" ON )
|
||||||
OPTION( USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF )
|
OPTION( USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF )
|
||||||
|
IF(HAVE_STRUCT_STAT_NSEC)
|
||||||
OPTION( USE_NSEC "Care about sub-second file mtimes and ctimes" OFF )
|
OPTION( USE_NSEC "Care about sub-second file mtimes and ctimes" OFF )
|
||||||
|
ENDIF()
|
||||||
OPTION( VALGRIND "Configure build for valgrind" OFF )
|
OPTION( VALGRIND "Configure build for valgrind" OFF )
|
||||||
OPTION( CURL "User curl for HTTP if available" ON)
|
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->ctime.seconds = (git_time_t)st->st_ctime;
|
||||||
entry->mtime.seconds = (git_time_t)st->st_mtime;
|
entry->mtime.seconds = (git_time_t)st->st_mtime;
|
||||||
#if !defined(GIT_WIN32) && !defined(__APPLE__)
|
#if defined(GIT_USE_NSEC)
|
||||||
/* Apple and Windows doesn't provide these struct stat fields. */
|
|
||||||
entry->mtime.nanoseconds = st->st_mtim.tv_nsec;
|
entry->mtime.nanoseconds = st->st_mtim.tv_nsec;
|
||||||
entry->ctime.nanoseconds = st->st_ctim.tv_nsec;
|
entry->ctime.nanoseconds = st->st_ctim.tv_nsec;
|
||||||
#endif
|
#endif
|
||||||
|
@ -164,8 +164,7 @@ static void hack_index(char *files[])
|
|||||||
|
|
||||||
entry->ctime.seconds = (git_time_t)statbuf.st_ctime;
|
entry->ctime.seconds = (git_time_t)statbuf.st_ctime;
|
||||||
entry->mtime.seconds = (git_time_t)statbuf.st_mtime;
|
entry->mtime.seconds = (git_time_t)statbuf.st_mtime;
|
||||||
#if !defined(GIT_WIN32) && !defined(__APPLE__)
|
#if defined(GIT_USE_NSEC)
|
||||||
/* Apple and Windows doesn't provide these struct stat fields. */
|
|
||||||
entry->ctime.nanoseconds = statbuf.st_ctim.tv_nsec;
|
entry->ctime.nanoseconds = statbuf.st_ctim.tv_nsec;
|
||||||
entry->mtime.nanoseconds = statbuf.st_mtim.tv_nsec;
|
entry->mtime.nanoseconds = statbuf.st_mtim.tv_nsec;
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user