-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
67 lines (62 loc) · 2.14 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
cmake_minimum_required(VERSION 3.5)
project (clibs C)
if (MSVC)
add_compile_options(/WX)
if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
else()
add_compile_options(/W4)
endif()
endif (MSVC)
include (CheckFunctionExists)
include (CheckLibraryExists)
check_function_exists(_itoa _ITOA_FOUND)
if (NOT _ITOA_FOUND)
check_function_exists(itoa ITOA_FOUND)
endif(NOT _ITOA_FOUND)
if (_ITOA_FOUND)
add_compile_definitions(HAVE__ITOA=1)
elseif (ITOA_FOUND)
add_compile_definitions(HAVE_ITOA=1)
endif(_ITOA_FOUND)
check_function_exists(_strdup _STRDUP_FOUND)
if (NOT _STRDUP_FOUND)
check_function_exists(strdup STRDUP_FOUND)
endif(NOT _STRDUP_FOUND)
check_function_exists(strlcpy STRLCPY_FOUND)
check_function_exists(strlcat STRLCAT_FOUND)
if (_STRDUP_FOUND)
add_compile_definitions(HAVE__STRDUP=1)
elseif (STRDUP_FOUND)
add_compile_definitions(HAVE_STRDUP=1)
else (_STRDUP_FOUND)
check_library_exists(bsd strdup "" LIBBSD_FOUND)
endif (_STRDUP_FOUND)
if (STRLCPY_FOUND)
add_compile_definitions(HAVE_STRLCPY=1)
else (STRLCPY_FOUND)
check_library_exists(bsd strlcpy "" LIBBSD_FOUND)
endif(STRLCPY_FOUND)
if (STRLCAT_FOUND)
add_compile_definitions(HAVE_STRLCAT=1)
else (HAVE_STRLCAT_FOUND)
check_library_exists(bsd strlcat "" LIBBSD_FOUND)
endif(STRLCAT_FOUND)
if (LIBBSD_FOUND)
add_compile_definitions(HAVE_LIBBSD=1)
add_compile_definitions(HAVE_STRDUP=1)
add_compile_definitions(HAVE_STRLCPY=1)
add_compile_definitions(HAVE_STRLCAT=1)
endif (LIBBSD_FOUND)
file (GLOB LIB_HDR *.h)
add_library (${PROJECT_NAME} strings.c l10n.c strutil.c critbit.c selist.c format.c ${LIB_HDR})
add_library (cutest CuTest.c)
add_executable (test_clibs tests.c test_cmdline.c test_strings.c test_l10n.c test_selist.c test_strutil.c test_format.c test_critbit.c)
target_link_libraries (test_clibs cutest ${PROJECT_NAME})
if (LIBBSD_FOUND)
target_link_libraries (test_clibs bsd)
endif (LIBBSD_FOUND)
enable_testing()
add_test (NAME clibs COMMAND test_clibs)
set (CLIBS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "clibs headers")
set (CLIBS_LIBRARIES ${PROJECT_NAME} CACHE INTERNAL "single-file libraries")