summaryrefslogtreecommitdiff
path: root/src/CMakeLists.txt
diff options
context:
space:
mode:
authorEtienne Samson <samson.etienne@gmail.com>2018-08-17 15:56:30 +0000
committerEtienne Samson <samson.etienne@gmail.com>2018-08-24 22:00:05 +0200
commit1a9cc18260b68b149476adb6f39e37ab47d3d21f (patch)
tree532d1f75793b9fde27b1306c09e577ba16d0bc38 /src/CMakeLists.txt
parent8856337b35ad417db9fa5604f76086528cb0436b (diff)
downloadlibgit2-1a9cc18260b68b149476adb6f39e37ab47d3d21f.tar.gz
util: make the qsort_r check work on macOS
This performs a compile-check by using CMake support, to differentiate the GNU version from the BSD version of qsort_r. Module taken from 4f252abea5f1d17c60f6ff115c9c44cc0b6f1df6, which I've checked against CMake 2.8.11.
Diffstat (limited to 'src/CMakeLists.txt')
-rw-r--r--src/CMakeLists.txt17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index be733cc76..157ce8000 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -58,10 +58,19 @@ IF (HAVE_FUTIMENS)
SET(GIT_USE_FUTIMENS 1)
ENDIF ()
-CHECK_FUNCTION_EXISTS(qsort_r HAVE_QSORT_R)
-IF (HAVE_QSORT_R)
- ADD_DEFINITIONS(-DHAVE_QSORT_R)
-ENDIF ()
+CHECK_PROTOTYPE_DEFINITION(qsort_r
+ "void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))"
+ "" "stdlib.h" HAVE_QSORT_R_BSD)
+IF (HAVE_QSORT_R_BSD)
+ ADD_DEFINITIONS(-DHAVE_QSORT_R_BSD)
+ENDIF()
+
+CHECK_PROTOTYPE_DEFINITION(qsort_r
+ "void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg)"
+ "" "stdlib.h" HAVE_QSORT_R_GNU)
+IF (HAVE_QSORT_R_GNU)
+ ADD_DEFINITIONS(-DHAVE_QSORT_R_GNU)
+ENDIF()
CHECK_FUNCTION_EXISTS(qsort_s HAVE_QSORT_S)
IF (HAVE_QSORT_S)