cmake: check for GNU style strerror_r
authorMichael Wallner <mike@php.net>
Mon, 17 Aug 2020 09:05:21 +0000 (11:05 +0200)
committerMichael Wallner <mike@php.net>
Mon, 17 Aug 2020 09:05:21 +0000 (11:05 +0200)
CMake/CheckCompiles.cmake [new file with mode: 0644]
CMake/_Include.cmake
src/mem_config.h.in

diff --git a/CMake/CheckCompiles.cmake b/CMake/CheckCompiles.cmake
new file mode 100644 (file)
index 0000000..f03f1da
--- /dev/null
@@ -0,0 +1,16 @@
+include(CheckCXXSourceCompiles)
+
+function(check_compiles RESULT_VAR TEST)
+
+    unset(SOURCE)
+    foreach(HEADER IN LISTS ARGN)
+        string(APPEND SOURCE "#include <${HEADER}>\n")
+    endforeach()
+    string(APPEND SOURCE "
+            int main() {
+                ${TEST}
+                return 0;
+            }
+    ")
+    check_cxx_source_compiles("${SOURCE}" ${RESULT_VAR})
+endfunction()
index 0f25ab4875a6eb363f298ade9b2c5646a51ae3ea..67963844d64bc70531a2e096a732b6494aa6be63 100644 (file)
@@ -14,6 +14,7 @@ include(CheckDebug)
 include(CheckDecl)
 include(CheckDependency)
 include(CheckHeader)
+include(CheckCompiles)
 include(CheckType)
 include(CheckStdatomic)
 
@@ -34,7 +35,7 @@ if(ENABLE_DTRACE)
     set(HAVE_DTRACE 1)
 endif()
 
-##uuid
+## uuid
 if(BUILD_TESTING)
     check_dependency(LIBUUID uuid uuid/uuid.h)
 endif()
@@ -91,6 +92,7 @@ check_decl(MSG_NOSIGNAL sys/socket.h)
 check_decl(rcvtimeo sys/socket.h)
 check_decl(sndtimeo sys/socket.h)
 check_decl(strerror_r string.h)
+check_compiles(HAVE_STRERROR_R_CHAR_P "char x, y = *strerror_r(0,&x,1);" string.h)
 check_decl(strerror string.h)
 check_decl(abi::__cxa_demangle cxxabi.h)
 set(HAVE_GCC_ABI_DEMANGLE ${HAVE_ABI____CXA_DEMANGLE})
index de2cdb7aa472477cc8a6bb500eae1594ed1e5cb1..d27040950b3d658e6ec6c07dfc6d6f578189a944 100644 (file)
@@ -39,6 +39,7 @@
 #cmakedefine HAVE_STDLIB_H 1
 #cmakedefine HAVE_STRERROR 1
 #cmakedefine HAVE_STRERROR_R 1
+#cmakedefine HAVE_STRERROR_R_CHAR_P 1
 #cmakedefine HAVE_STRINGS_H 1
 #cmakedefine HAVE_SYS_SOCKET_H 1
 #cmakedefine HAVE_SYS_TIME_H 1