-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathCMakeLists.txt
113 lines (106 loc) · 2.5 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
add_executable(libc_tests)
# Workaround for the potential to have CMake block our include directory if
# -nostdinc is used and the header is in a CMake implicit include path
if(NOSTDINC_FOR_DEPENDENTS)
list(REMOVE_ITEM CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "${CMOCKA_INCLUDE_DIR}")
endif()
target_include_directories(libc_tests PRIVATE . test/)
target_link_libraries(libc_tests PRIVATE c_hosted cmocka_dep)
target_linker_map(libc_tests)
list(APPEND desired_libc_tests_flags
"-Wno-stringop-overflow"
"-Wno-unused-parameter"
"-Wno-nonnull-compare"
"-Wno-nonnull"
"-Wno-stringop-truncation"
"-Wno-unknown-pragmas"
)
apply_supported_compiler_flags(C libc_tests PRIVATE desired_libc_tests_flags)
if(NOT DISABLE_BUILTINS OR NOT (CMAKE_BUILD_TYPE STREQUAL "Debug"))
target_compile_definitions(libc_tests PRIVATE BUILTINS_ARE_ENABLED)
endif()
target_sources(libc_tests PRIVATE
main.c
ctype/ctype_tests.c
ctype/isalnum.c
ctype/isalpha.c
ctype/isascii.c
ctype/isblank.c
ctype/iscntrl.c
ctype/isdigit.c
ctype/isgraph.c
ctype/islower.c
ctype/isprint.c
ctype/ispunct.c
ctype/isspace.c
ctype/isupper.c
ctype/isxdigit.c
ctype/toascii.c
ctype/tolower.c
ctype/toupper.c
stdlib/abs.c
stdlib/atof.c
stdlib/atoi.c
stdlib/atol.c
stdlib/atoll.c
stdlib/bsearch.c
stdlib/calloc.c
stdlib/div.c
stdlib/heapsort.c
stdlib/imaxabs.c
stdlib/imaxdiv.c
stdlib/labs.c
stdlib/ldiv.c
stdlib/llabs.c
stdlib/lldiv.c
stdlib/qsort_r.c
stdlib/qsort.c
stdlib/rand.c
stdlib/realloc.c
stdlib/stdlib_tests.c
stdlib/strtod.c
stdlib/strtof.c
stdlib/strtol.c
stdlib/strtoll.c
stdlib/strtoul.c
stdlib/strtoull.c
string/memcmp.c
string/memcpy.c
string/memmem.c
string/memmove.c
string/memset.c
string/strcat.c
string/strchr.c
string/strcmp.c
string/strcpy.c
string/strdup.c
string/string_tests.c
string/strlen.c
string/strncat.c
string/strncmp.c
string/strncpy.c
string/strndup.c
string/strnlen.c
string/strnstr.c
string/strrchr.c
string/strstr.c
string/strtok.c
test/rand.c
test/ulpsDistance.c
)
#################
# Register Test #
#################
register_cmocka_test(Libc.Test libc_tests)
########################
# Barebones Executable #
########################
# This barebones executable can be used to test linking when cross-compiling
if(CMAKE_CROSSCOMPILING AND (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME))
add_executable(sample_app)
target_sources(sample_app PRIVATE app/main.c)
target_link_libraries(sample_app PRIVATE c)
target_linker_map(sample_app)
convert_to_hex(sample_app)
convert_to_bin(sample_app)
endif()