barbieri pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=85a095f0a88ef803e1eb98664b83116e2614c4ce

commit 85a095f0a88ef803e1eb98664b83116e2614c4ce
Author: Gustavo Sverzut Barbieri <[email protected]>
Date:   Thu Jan 26 15:35:35 2017 -0200

    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.
---
 cmake/config/common.cmake   | 8 +++++++-
 src/lib/eina/CMakeLists.txt | 4 ++++
 src/lib/eina/eina_str.c     | 4 ++++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/cmake/config/common.cmake b/cmake/config/common.cmake
index 2e31bf4..be69a89 100644
--- a/cmake/config/common.cmake
+++ b/cmake/config/common.cmake
@@ -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)
 
diff --git a/src/lib/eina/CMakeLists.txt b/src/lib/eina/CMakeLists.txt
index bd23e78..4c5ee50 100644
--- a/src/lib/eina/CMakeLists.txt
+++ b/src/lib/eina/CMakeLists.txt
@@ -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
diff --git a/src/lib/eina/eina_str.c b/src/lib/eina/eina_str.c
index dcf93c3..b9f0c03 100644
--- a/src/lib/eina/eina_str.c
+++ b/src/lib/eina/eina_str.c
@@ -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>

-- 


Reply via email to