cmake: fix strlcpy() detection and usage.

Linux usually ship with strlcpy(), but it's inside bsd/string.h and
needs -lbsd.

On BSD it's inside string.h and libc.
This commit is contained in:
Gustavo Sverzut Barbieri 2017-01-26 15:35:35 -02:00
parent 4ed139a49c
commit 85a095f0a8
3 changed files with 15 additions and 1 deletions

View File

@ -36,6 +36,7 @@ EFL_OPTION(ENABLE_VALGRIND "Enable valgrind support" "${SUGGEST_VALGRIND}" DEPEN
HEADER_CHECK(alloca.h)
HEADER_CHECK(asm/hwcap.h)
HEADER_CHECK(bsd/string.h)
HEADER_CHECK(dirent.h)
HEADER_CHECK(execinfo.h)
HEADER_CHECK(mcheck.h)
@ -80,7 +81,12 @@ FUNC_CHECK(shm_open INCLUDE_FILES sys/mman.h sys/stat.h fcntl.h LIBRARIES rt)
FUNC_CHECK(siglongjmp INCLUDE_FILES setjmp.h)
FUNC_CHECK(splice INCLUDE_FILES fcntl.h DEFINITIONS "-D_GNU_SOURCE=1")
FUNC_CHECK(strerror_r INCLUDE_FILES string.h)
FUNC_CHECK(strlcpy INCLUDE_FILES bsd/string.h)
if(HAVE_BSD_STRING_H)
FUNC_CHECK(strlcpy INCLUDE_FILES bsd/string.h LIBRARIES bsd)
else()
FUNC_CHECK(strlcpy INCLUDE_FILES string.h)
endif()
TYPE_CHECK(siginfo_t INCLUDE_FILES signal.h)

View File

@ -22,6 +22,10 @@ set(LIBRARIES
rt
)
if(HAVE_BSD_STRING_H)
list(APPEND LIBRARIES bsd)
endif()
set(PUBLIC_HEADERS
Eina.h
eina_accessor.h

View File

@ -28,6 +28,10 @@
#include <limits.h>
#include <ctype.h>
#ifdef HAVE_BSD_STRING_H
# include <bsd/string.h>
#endif
#ifdef HAVE_ICONV
# include <errno.h>
# include <iconv.h>