have cmake determine bsdstring requirement

This commit is contained in:
Enno Rehling 2017-12-11 08:53:10 +01:00
parent b297b4d43c
commit d48b9611e1
5 changed files with 26 additions and 3 deletions

View File

@ -11,6 +11,9 @@ if (MSVC)
include(MSVC)
endif (MSVC)
INCLUDE (CheckSymbolExists)
CHECK_SYMBOL_EXISTS(strlcat string.h HAVE_STRLCAT)
find_package (SQLite3)
find_package (BerkeleyDB)
find_package (Curses)

View File

@ -266,6 +266,10 @@ add_test(server test_eressea)
install(TARGETS eressea DESTINATION "bin")
if (HAVE_STRLCAT)
add_definitions(-DHAVE_BSDSTRING)
endif(HAVE_STRLCAT)
if (DB_FOUND)
include_directories (${DB_INCLUDE_DIR})
target_link_libraries(convert ${DB_LIBRARIES})

View File

@ -29,8 +29,8 @@
#endif
#define _POSIX_C_SOURCE 200809L
/* #define _POSIX_C_SOURCE 200809L
*/
#ifndef MAX_PATH
# define MAX_PATH 4096
#endif

View File

@ -3,7 +3,6 @@ project(util C)
SET(_TEST_FILES
attrib.test.c
base36.test.c
bsdstring.test.c
# crmessage.test.c
# dice.test.c
# event.test.c
@ -60,6 +59,12 @@ unicode.c
variant.c
xml.c
)
IF(HAVE_BSDSTRING)
SET (_TEST_FILES ${_TEST_FILES} bsdstring.test.c)
SET (_FILES ${_FILES} bsdstring.c)
ENDIF(HAVE_BSDSTRING)
FOREACH(_FILE ${_FILES})
LIST(APPEND _SOURCES ${PROJECT_NAME}/${_FILE})
ENDFOREACH(_FILE)

View File

@ -4,6 +4,17 @@
#include <stddef.h>
int wrptr(char **ptr, size_t * size, int bytes);
#undef HAVE_STRLCAT
#undef HAVE_STRLCPY
#undef HAVE_SLPRINTF
#ifdef HAVE_BSDSTRING
#define HAVE_STRLCAT
#define HAVE_SLPRINT
#define HAVE_STRLCPY
#else
#include <string.h>
#endif
#ifndef HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t siz);
#endif