From: Michael Wallner Date: Mon, 17 Aug 2020 09:05:21 +0000 (+0200) Subject: cmake: check for GNU style strerror_r X-Git-Tag: 1.1.0-beta1~247 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=169e219154873be30faaa026d09847f438bbea51;p=m6w6%2Flibmemcached cmake: check for GNU style strerror_r --- diff --git a/CMake/CheckCompiles.cmake b/CMake/CheckCompiles.cmake new file mode 100644 index 00000000..f03f1da4 --- /dev/null +++ b/CMake/CheckCompiles.cmake @@ -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() diff --git a/CMake/_Include.cmake b/CMake/_Include.cmake index 0f25ab48..67963844 100644 --- a/CMake/_Include.cmake +++ b/CMake/_Include.cmake @@ -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}) diff --git a/src/mem_config.h.in b/src/mem_config.h.in index de2cdb7a..d2704095 100644 --- a/src/mem_config.h.in +++ b/src/mem_config.h.in @@ -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