1 function(add_fp_unittest name)
4 "NEED_MPFR;UNIT_TEST_ONLY;HERMETIC_TEST_ONLY" # Optional arguments
5 "" # Single value arguments
6 "LINK_LIBRARIES;DEPENDS" # Multi-value arguments
10 if(MATH_UNITTEST_NEED_MPFR)
11 if(NOT LIBC_TESTS_CAN_USE_MPFR)
12 message(VERBOSE "Math test ${name} will be skipped as MPFR library is not available.")
17 if(MATH_UNITTEST_HERMETIC_TEST_ONLY)
18 set(test_type HERMETIC_TEST_ONLY)
19 elseif(MATH_UNITTEST_UNIT_TEST_ONLY)
20 set(test_type UNIT_TEST_ONLY)
22 if(MATH_UNITTEST_NEED_MPFR)
23 if(MATH_UNITTEST_HERMETIC_TEST_ONLY)
24 message(FATAL_ERROR "Hermetic math test cannot require MPFR.")
26 set(test_type UNIT_TEST_ONLY)
27 list(APPEND MATH_UNITTEST_LINK_LIBRARIES libcMPFRWrapper -lmpfr -lgmp)
28 if(NOT(LIBC_TARGET_OS_IS_DARWIN))
29 # macOS does not have libatomic.
30 list(APPEND MATH_UNITTEST_LINK_LIBRARIES -latomic)
33 list(APPEND MATH_UNITTEST_LINK_LIBRARIES LibcFPTestHelpers)
35 set(deps libc.hdr.math_macros)
36 if(MATH_UNITTEST_DEPENDS)
37 list(APPEND deps ${MATH_UNITTEST_DEPENDS})
43 LINK_LIBRARIES "${MATH_UNITTEST_LINK_LIBRARIES}"
44 "${MATH_UNITTEST_UNPARSED_ARGUMENTS}"
47 endfunction(add_fp_unittest)
49 add_subdirectory(__support)
50 add_subdirectory(complex)
51 add_subdirectory(ctype)
52 add_subdirectory(errno)
53 add_subdirectory(fenv)
54 add_subdirectory(math)
55 add_subdirectory(search)
56 add_subdirectory(stdbit)
57 add_subdirectory(stdfix)
58 add_subdirectory(stdio)
59 add_subdirectory(stdlib)
60 add_subdirectory(string)
61 add_subdirectory(wchar)
63 # Depends on utilities in stdlib
64 add_subdirectory(inttypes)
66 if(${LIBC_TARGET_OS} STREQUAL "linux")
67 add_subdirectory(fcntl)
68 add_subdirectory(sched)
70 add_subdirectory(termios)
71 add_subdirectory(unistd)
74 if(NOT LLVM_LIBC_FULL_BUILD)
78 add_subdirectory(assert)
79 add_subdirectory(compiler)
80 add_subdirectory(dirent)
81 add_subdirectory(network)
82 add_subdirectory(setjmp)
83 add_subdirectory(signal)
84 add_subdirectory(spawn)
85 add_subdirectory(time)
86 add_subdirectory(locale)
88 if(${LIBC_TARGET_OS} STREQUAL "linux")
89 add_subdirectory(pthread)
92 if(LLVM_RUNTIMES_BUILD OR LIBC_HDRGEN_EXE)
93 # The public API test below uses tablegen to generate the test
94 # source file. Since tablegen is not available during a runtimes
95 # build, we will skip the test.
96 # If a different libc-hdrgen binary is being used, then also we
97 # skip the api-test as we cannot generate the test source file.
101 set(public_test ${CMAKE_CURRENT_BINARY_DIR}/public_api_test.cpp)
103 set(entrypoints_name_list "")
104 foreach(entry IN LISTS TARGET_LLVMLIBC_ENTRYPOINTS)
105 get_target_property(entry_name ${entry} "ENTRYPOINT_NAME")
106 list(APPEND entrypoints_name_list ${entry_name})
109 # TODO: Remove these when they are added to the TableGen.
110 list(REMOVE_ITEM entrypoints_name_list "__assert_fail" "__errno_location")
111 list(TRANSFORM entrypoints_name_list PREPEND "-e=")
113 file(GLOB spec_files ${LIBC_SOURCE_DIR}/spec/*.td)
115 # Generate api test souce code.
117 OUTPUT ${public_test}
118 COMMAND $<TARGET_FILE:libc-prototype-testgen> -o ${public_test}
119 ${entrypoints_name_list}
120 -I ${LIBC_SOURCE_DIR}
121 ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td
123 DEPENDS ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td ${spec_files}
124 libc-prototype-testgen ${TARGET_PUBLIC_HEADERS}
128 add_custom_target(libc-api-test)
129 add_dependencies(check-libc libc-api-test)
132 allocator_entrypoints
133 libc.src.stdlib.malloc
134 libc.src.stdlib.calloc
135 libc.src.stdlib.realloc
136 libc.src.stdlib.aligned_alloc
139 set(api-test-entrypoints ${TARGET_LLVMLIBC_ENTRYPOINTS})
140 list(REMOVE_ITEM api-test-entrypoints ${allocator_entrypoints})
141 add_integration_test(
148 ${api-test-entrypoints}
151 if(COMPILER_RESOURCE_DIR AND LLVM_LIBC_ENABLE_LINTING)
155 COMMAND ${LLVM_LIBC_CLANG_TIDY} --system-headers
156 --checks=-*,llvmlibc-restrict-system-libc-headers
157 "--extra-arg=-resource-dir=${COMPILER_RESOURCE_DIR}"
159 --warnings-as-errors=llvmlibc-*
160 "-config={CheckOptions: [{key: llvmlibc-restrict-system-libc-headers.Includes, value: '-*, linux/*, asm/*.h, asm-generic/*.h'}]}"
162 -p ${PROJECT_BINARY_DIR}
165 clang-tidy ${public_test}
167 add_dependencies(libc-api-test libc-api-test-tidy)