Commit 8341d6cf839d46dc382db96b7dd50ec9777e7244

Patrick Steinhardt 2017-07-04T10:57:28

cmake: move regcomp and futimens checks to "features.h" In our CMakeLists.txt, we have to check multiple functions in order to determine if we have to use our own or whether we can use the platform-provided one. For two of these functions, namely `regcomp_l()` and `futimens`, the defined macro is actually used inside of the header file "src/unix/posix.h". As such, these macros are not only required by the library, but also by our test suite, which is makes use of internal headers. To prepare for the CMakeLists.txt split, move these two defines inside of the "features.h" header.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3f9ecd8..7df5b71 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -520,12 +520,12 @@ ENDIF()
 
 CHECK_SYMBOL_EXISTS(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L)
 IF (HAVE_REGCOMP_L)
-	ADD_DEFINITIONS(-DHAVE_REGCOMP_L)
+	SET(GIT_USE_REGCOMP_L 1)
 ENDIF ()
 
 CHECK_FUNCTION_EXISTS(futimens HAVE_FUTIMENS)
 IF (HAVE_FUTIMENS)
-	ADD_DEFINITIONS(-DHAVE_FUTIMENS)
+	SET(GIT_USE_FUTIMENS 1)
 ENDIF ()
 
 CHECK_FUNCTION_EXISTS(qsort_r HAVE_QSORT_R)
diff --git a/src/features.h.in b/src/features.h.in
index c3fcc51..e03b7a2 100644
--- a/src/features.h.in
+++ b/src/features.h.in
@@ -14,6 +14,8 @@
 #cmakedefine GIT_USE_STAT_MTIM 1
 #cmakedefine GIT_USE_STAT_MTIMESPEC 1
 #cmakedefine GIT_USE_STAT_MTIME_NSEC 1
+#cmakedefine GIT_USE_FUTIMENS 1
+#cmakedefine GIT_USE_REGCOMP_L 1
 
 #cmakedefine GIT_SSH 1
 #cmakedefine GIT_SSH_MEMORY_CREDENTIALS 1
diff --git a/src/unix/posix.h b/src/unix/posix.h
index 5483419..bfabd17 100644
--- a/src/unix/posix.h
+++ b/src/unix/posix.h
@@ -72,7 +72,7 @@ GIT_INLINE(int) p_fsync(int fd)
 
 #define p_timeval timeval
 
-#ifdef HAVE_FUTIMENS
+#ifdef GIT_USE_FUTIMENS
 GIT_INLINE(int) p_futimes(int f, const struct p_timeval t[2])
 {
 	struct timespec s[2];
@@ -86,7 +86,7 @@ GIT_INLINE(int) p_futimes(int f, const struct p_timeval t[2])
 # define p_futimes futimes
 #endif
 
-#ifdef HAVE_REGCOMP_L
+#ifdef GIT_USE_REGCOMP_L
 #include <xlocale.h>
 GIT_INLINE(int) p_regcomp(regex_t *preg, const char *pattern, int cflags)
 {