Skip to content

Commit 3062a63

Browse files
committed
cmake: extended futimens checking on macOS
1 parent e5975f3 commit 3062a63

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ INCLUDE(AddCFlagIfSupported)
2727
INCLUDE(FindPkgLibraries)
2828
INCLUDE(FindThreads)
2929
INCLUDE(FindStatNsec)
30+
INCLUDE(Findfutimens)
3031
INCLUDE(GNUInstallDirs)
3132
INCLUDE(IdeSplitSources)
3233
INCLUDE(FeatureSummary)

cmake/Findfutimens.cmake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
INCLUDE(EnableWarnings)
2+
3+
IF (APPLE)
4+
# We cannot simply CHECK_FUNCTION_EXISTS on macOS because
5+
# MACOSX_DEPLOYMENT_TARGET may be set to a version in the past
6+
# that doesn't have futimens. Instead we need to enable warnings
7+
# as errors, then check for the symbol existing in `sys/stat.h`,
8+
# then reset warnings as errors.
9+
ENABLE_WARNINGS(error)
10+
CHECK_SYMBOL_EXISTS(futimens sys/stat.h HAVE_FUTIMENS)
11+
DISABLE_WARNINGS(error)
12+
ELSE ()
13+
CHECK_FUNCTION_EXISTS(futimens HAVE_FUTIMENS)
14+
ENDIF ()

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ IF(ENABLE_TRACE)
3838
ENDIF()
3939
ADD_FEATURE_INFO(tracing GIT_TRACE "tracing support")
4040

41-
CHECK_FUNCTION_EXISTS(futimens HAVE_FUTIMENS)
4241
IF (HAVE_FUTIMENS)
4342
SET(GIT_USE_FUTIMENS 1)
4443
ENDIF ()
44+
ADD_FEATURE_INFO(futimens GIT_USE_FUTIMENS "futimens support")
4545

4646
CHECK_PROTOTYPE_DEFINITION(qsort_r
4747
"void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))"

0 commit comments

Comments
 (0)