From 184914b8de1136e868730dbd337846a2875791be Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Tue, 1 Dec 2015 15:07:48 +0100 Subject: [PATCH] cmake: define STRERROR_R_CHAR_P for GNU-specific strerror_r This is what autotools does with AC_FUNC_STRERROR_R bit. It takes us from $ monmaptool --print nonexistant monmaptool: monmap file nonexistant monmaptool: couldn't open nonexistant: (2) to $ monmaptool --print nonexistant monmaptool: monmap file nonexistant monmaptool: couldn't open nonexistant: (2) No such file or directory on cmake - otherwise we end up using GNU-specific version as if it was the POSIX version. Signed-off-by: Ilya Dryomov --- CMakeLists.txt | 6 ++++++ src/include/config-h.in.cmake | 3 +++ 2 files changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1aff1ab9a315..cb41d3ea286b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,6 +85,12 @@ CHECK_SYMBOL_EXISTS(__s64 "sys/types.h;linux/types.h" HAVE___S64) CHECK_SYMBOL_EXISTS(res_nquery "resolv.h" HAVE_RES_NQUERY) +include(CheckCXXSourceCompiles) +CHECK_CXX_SOURCE_COMPILES(" + #include + int main() { char x = *strerror_r(0, &x, sizeof(x)); return 0; } + " STRERROR_R_CHAR_P) + set(CEPH_MAN_DIR "share/man" CACHE STRING "Install location for man pages (relative to prefix).") option(ENABLE_SHARED "build shared libraries" ON) diff --git a/src/include/config-h.in.cmake b/src/include/config-h.in.cmake index 65921c60250c..1907a98ce998 100644 --- a/src/include/config-h.in.cmake +++ b/src/include/config-h.in.cmake @@ -176,6 +176,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_UTIME_H +/* Define to 1 if strerror_r returns char *. */ +#cmakedefine STRERROR_R_CHAR_P 1 + /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #cmakedefine LT_OBJDIR -- 2.47.3