From 4df6baa5ac4c9d96d5209b4f49390dc52a25f09d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Bri=C3=A8re?= Date: Mon, 12 Feb 2018 19:22:53 -0500 Subject: 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. --- CMakeLists.txt | 16 ++++++++++++++++ src/util.cpp | 4 ++-- 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 + 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}" -- cgit v1.2.3 From 87e996aaebdae6e2f07c8aa650b4eebdd00f0cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Bri=C3=A8re?= Date: Mon, 12 Feb 2018 19:28:16 -0500 Subject: CMake: Check for res_init() (HAVE_RES_INIT) This check (AC_CHECK_RES_INIT) was originally defined in acinclude.m4, and was lost in the transition to CMake. --- CMakeLists.txt | 13 +++++++++++++ src/sockets/dnssrv.cpp | 1 + twinkle_config.h.in | 1 + 3 files changed, 15 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 959bd26..ce718da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") include (CheckIncludeFile) include (CheckIncludeFiles) include (CheckSymbolExists) +include (CMakePushCheckState) include (CheckCXXSourceCompiles) find_package(LibXml2 REQUIRED) @@ -137,6 +138,18 @@ if (HAVE_STRERROR_R) " STRERROR_R_CHAR_P) endif (HAVE_STRERROR_R) +cmake_push_check_state() +list(APPEND CMAKE_REQUIRED_LIBRARIES "-lresolv") +check_cxx_source_compiles(" + #include + #include + #include + #include + + int main() { res_init(); return 0; } +" HAVE_RES_INIT) +cmake_pop_check_state() + 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/sockets/dnssrv.cpp b/src/sockets/dnssrv.cpp index 38cd61d..246bf02 100644 --- a/src/sockets/dnssrv.cpp +++ b/src/sockets/dnssrv.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "twinkle_config.h" #include #include #include diff --git a/twinkle_config.h.in b/twinkle_config.h.in index b7c678c..9e32712 100644 --- a/twinkle_config.h.in +++ b/twinkle_config.h.in @@ -10,6 +10,7 @@ #cmakedefine HAVE_LINUX_ERRQUEUE_H #cmakedefine HAVE_STRERROR_R #cmakedefine STRERROR_R_CHAR_P +#cmakedefine HAVE_RES_INIT #cmakedefine HAVE_LIBASOUND #define VERSION "${PRODUCT_VERSION}" -- cgit v1.2.3 From 5635f7c2483c4ceac5c0e1cf5e522f7be32fd2f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Bri=C3=A8re?= Date: Mon, 12 Feb 2018 20:02:11 -0500 Subject: CMake: Check for endianness (WORDS_BIGENDIAN) This check (AC_C_BIGENDIAN) was originally present in configure.in, and was lost in the transition to CMake. --- CMakeLists.txt | 3 +++ twinkle_config.h.in | 1 + 2 files changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce718da..c20bd16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ include (CheckIncludeFiles) include (CheckSymbolExists) include (CMakePushCheckState) include (CheckCXXSourceCompiles) +include (TestBigEndian) find_package(LibXml2 REQUIRED) find_package(LibMagic REQUIRED) @@ -150,6 +151,8 @@ check_cxx_source_compiles(" " HAVE_RES_INIT) cmake_pop_check_state() +test_big_endian(WORDS_BIGENDIAN) + 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/twinkle_config.h.in b/twinkle_config.h.in index 9e32712..2f03cf2 100644 --- a/twinkle_config.h.in +++ b/twinkle_config.h.in @@ -11,6 +11,7 @@ #cmakedefine HAVE_STRERROR_R #cmakedefine STRERROR_R_CHAR_P #cmakedefine HAVE_RES_INIT +#cmakedefine WORDS_BIGENDIAN #cmakedefine HAVE_LIBASOUND #define VERSION "${PRODUCT_VERSION}" -- cgit v1.2.3 From 6952b81fe89a136c0d087aa98cfbfd8bfc965818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Bri=C3=A8re?= Date: Tue, 13 Feb 2018 10:29:31 -0500 Subject: CMake: Check if libilbc links without 'extern "C"' (ILBC_CPP) This variable was originally set manually in configure.in. --- CMakeLists.txt | 3 +++ cmake/FindIlbc.cmake | 19 +++++++++++++++++++ twinkle_config.h.in | 1 + 3 files changed, 23 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c20bd16..5e347b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,9 @@ if (WITH_ILBC) if (ILBC_FOUND) message(STATUS "iLBC OK") set(HAVE_ILBC TRUE) + if (ILBC_CPP) + set(HAVE_ILBC_CPP TRUE) + endif (ILBC_CPP) include_directories(${ILBC_INCLUDE_DIR}) else (ILBC_FOUND) diff --git a/cmake/FindIlbc.cmake b/cmake/FindIlbc.cmake index f66ca55..7bbffa9 100644 --- a/cmake/FindIlbc.cmake +++ b/cmake/FindIlbc.cmake @@ -1,8 +1,27 @@ +include (CMakePushCheckState) +include (CheckCXXSourceCompiles) + FIND_PATH(ILBC_INCLUDE_DIR ilbc/iLBC_decode.h) FIND_LIBRARY(ILBC_LIBRARIES NAMES ilbc) IF(ILBC_INCLUDE_DIR AND ILBC_LIBRARIES) SET(ILBC_FOUND TRUE) + + # Check if libilbc can be used without 'extern "C"' + CMAKE_PUSH_CHECK_STATE() + LIST(APPEND CMAKE_REQUIRED_INCLUDES "${ILBC_INCLUDE_DIR}") + LIST(APPEND CMAKE_REQUIRED_LIBRARIES "-lilbc") + SET(CMAKE_REQUIRED_QUIET TRUE) + CHECK_CXX_SOURCE_COMPILES(" + #include + + int main() { + iLBC_Dec_Inst_t *iLBCdec_inst; + initDecode(iLBCdec_inst, 0, 0); + return 0; + } + " ILBC_CPP) + CMAKE_POP_CHECK_STATE() ENDIF(ILBC_INCLUDE_DIR AND ILBC_LIBRARIES) IF(ILBC_FOUND) diff --git a/twinkle_config.h.in b/twinkle_config.h.in index 2f03cf2..4e649f7 100644 --- a/twinkle_config.h.in +++ b/twinkle_config.h.in @@ -1,6 +1,7 @@ #cmakedefine WITH_DIAMONDCARD #cmakedefine HAVE_SPEEX #cmakedefine HAVE_ILBC +#cmakedefine HAVE_ILBC_CPP #cmakedefine HAVE_ZRTP #cmakedefine HAVE_BCG729 #cmakedefine HAVE_GSM -- cgit v1.2.3