From 6fc298088e322103b205c62302e724ecd23aacbf Mon Sep 17 00:00:00 2001 From: Jan David Mol <mol@astron.nl> Date: Wed, 5 Dec 2012 20:04:37 +0000 Subject: [PATCH] Task #3696: Added HAVE_STRNLEN, because strnlen() is GNU only --- CMake/LofarGeneral.cmake | 12 ++++++++++++ lofar_config.h.cmake | 3 +++ 2 files changed, 15 insertions(+) diff --git a/CMake/LofarGeneral.cmake b/CMake/LofarGeneral.cmake index b72c4c4e76c..8b3d76537ac 100644 --- a/CMake/LofarGeneral.cmake +++ b/CMake/LofarGeneral.cmake @@ -126,6 +126,18 @@ if(NOT DEFINED LOFAR_GENERAL_INCLUDED) }" HAVE_GETPROTOBYNAME_R) endif(HAVE_NETDB_H) + ## -------------------------------------------------------------------------- + ## Define `STRNLEN', if the strnlen() function exists. + ## -------------------------------------------------------------------------- + check_c_source_compiles(" + #include <string.h> + #include <stdio.h> + int main() { + char *s = \"test\"; + int i = 3; + unsigned l = strnlen(s,i); + }" HAVE_STRNLEN) + ## -------------------------------------------------------------------------- ## Define custom target 'check', so that we can do 'make check', like we did ## with the GNU Autotools. Tests should be added with lofar_add_test(). diff --git a/lofar_config.h.cmake b/lofar_config.h.cmake index bc66715589f..901d33f2077 100644 --- a/lofar_config.h.cmake +++ b/lofar_config.h.cmake @@ -172,3 +172,6 @@ /* Define to 1 if you have a declaration for the `getprotobyname_r' function. */ #cmakedefine HAVE_GETPROTOBYNAME_R 1 + +/* Define to 1 if you have a declaration for the `strnlen' function. */ +#cmakedefine HAVE_STRNLEN 1 -- GitLab