diff options
author | Frédéric Brière <fbriere@fbriere.net> | 2018-02-12 19:22:53 -0500 |
---|---|---|
committer | Frédéric Brière <fbriere@fbriere.net> | 2019-12-29 02:39:51 -0500 |
commit | 4df6baa5ac4c9d96d5209b4f49390dc52a25f09d (patch) | |
tree | ad63c58ba4fc126d0331b422776c016f4cca9f64 | |
parent | 05082ae12051821b1d969e6672d9e4e5afe1bc07 (diff) | |
download | twinkle-4df6baa5ac4c9d96d5209b4f49390dc52a25f09d.tar twinkle-4df6baa5ac4c9d96d5209b4f49390dc52a25f09d.tar.gz twinkle-4df6baa5ac4c9d96d5209b4f49390dc52a25f09d.tar.lz twinkle-4df6baa5ac4c9d96d5209b4f49390dc52a25f09d.tar.xz twinkle-4df6baa5ac4c9d96d5209b4f49390dc52a25f09d.zip |
CMake: Check for strerror_r() (HAVE_STRERROR_R and STRERROR_R_CHAR_P)
This check (AC_FUNC_STRERROR_R) was originally present in configure.in,
and was lost in the transition to CMake.
-rw-r--r-- | CMakeLists.txt | 16 | ||||
-rw-r--r-- | src/util.cpp | 4 | ||||
-rw-r--r-- | twinkle_config.h.in | 2 |
3 files changed, 20 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5315383..959bd26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") include (CheckIncludeFile) include (CheckIncludeFiles) +include (CheckSymbolExists) +include (CheckCXXSourceCompiles) find_package(LibXml2 REQUIRED) find_package(LibMagic REQUIRED) @@ -121,6 +123,20 @@ check_include_file(unistd.h HAVE_UNISTD_H) check_include_file(linux/types.h HAVE_LINUX_TYPES_H) check_include_files("sys/socket.h;linux/errqueue.h" HAVE_LINUX_ERRQUEUE_H) +check_symbol_exists(strerror_r "string.h" HAVE_STRERROR_R) +if (HAVE_STRERROR_R) + # Check whether the return type is (int) or (char *) + # Code taken from Apache Thrift's ConfigureChecks.cmake + check_cxx_source_compiles(" + #include <string.h> + int main() { + char b; + char *a = strerror_r(0, &b, 0); + return 0; + } + " STRERROR_R_CHAR_P) +endif (HAVE_STRERROR_R) + set(datadir "${CMAKE_INSTALL_PREFIX}/share/twinkle") configure_file(twinkle_config.h.in twinkle_config.h) configure_file(twinkle.desktop.in twinkle.desktop) diff --git a/src/util.cpp b/src/util.cpp index 29aae39..60564a1 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -742,10 +742,10 @@ string to_printable(const string &s) { } string get_error_str(int errnum) { -#if HAVE_STRERROR_R +#ifdef HAVE_STRERROR_R char buf[81]; memset(buf, 0, sizeof(buf)); -#if STRERROR_R_CHAR_P +#ifdef STRERROR_R_CHAR_P string errmsg(strerror_r(errnum, buf, sizeof(buf)-1)); #else string errmsg; diff --git a/twinkle_config.h.in b/twinkle_config.h.in index 3928565..b7c678c 100644 --- a/twinkle_config.h.in +++ b/twinkle_config.h.in @@ -8,6 +8,8 @@ #cmakedefine HAVE_UNISTD_H #cmakedefine HAVE_LINUX_TYPES_H #cmakedefine HAVE_LINUX_ERRQUEUE_H +#cmakedefine HAVE_STRERROR_R +#cmakedefine STRERROR_R_CHAR_P #cmakedefine HAVE_LIBASOUND #define VERSION "${PRODUCT_VERSION}" |