1 function(add_fp_unittest name)
4 "NEED_MPFR" # Optional arguments
5 "" # Single value arguments
6 "LINK_LIBRARIES" # Multi-value arguments
10 if(MATH_UNITTEST_NEED_MPFR)
11 if(NOT LIBC_TESTS_CAN_USE_MPFR)
12 message("WARNING: Math test ${name} will be skipped as MPFR library is not available.")
17 if(MATH_UNITTEST_NEED_MPFR)
18 list(APPEND MATH_UNITTEST_LINK_LIBRARIES libcMPFRWrapper -lmpfr -lgmp)
20 list(APPEND MATH_UNITTEST_LINK_LIBRARIES LibcFPTestHelpers)
24 LINK_LIBRARIES "${MATH_UNITTEST_LINK_LIBRARIES}"
25 "${MATH_UNITTEST_UNPARSED_ARGUMENTS}"
27 endfunction(add_fp_unittest)
29 add_subdirectory(__support)
30 add_subdirectory(ctype)
31 add_subdirectory(errno)
32 add_subdirectory(fenv)
33 add_subdirectory(math)
34 add_subdirectory(string)
35 add_subdirectory(stdlib)
36 add_subdirectory(inttypes)
37 add_subdirectory(stdio)
39 if(${LIBC_TARGET_OS} STREQUAL "linux")
40 add_subdirectory(fcntl)
41 add_subdirectory(sched)
43 add_subdirectory(termios)
44 add_subdirectory(unistd)
47 if(NOT LLVM_LIBC_FULL_BUILD)
51 add_subdirectory(dirent)
52 add_subdirectory(assert)
53 add_subdirectory(network)
54 add_subdirectory(setjmp)
55 add_subdirectory(signal)
56 add_subdirectory(spawn)
57 add_subdirectory(time)
59 if(${LIBC_TARGET_OS} STREQUAL "linux")
60 add_subdirectory(pthread)
63 if(LLVM_RUNTIMES_BUILD OR LIBC_HDRGEN_EXE)
64 # The public API test below uses tablegen to generate the test
65 # source file. Since tablegen is not available during a runtimes
66 # build, we will skip the test.
67 # If a different libc-hdrgen binary is being used, then also we
68 # skip the api-test as we cannot generate the test source file.
72 set(public_test ${CMAKE_CURRENT_BINARY_DIR}/public_api_test.cpp)
74 set(entrypoints_name_list "")
75 foreach(entry IN LISTS TARGET_LLVMLIBC_ENTRYPOINTS)
76 get_target_property(entry_name ${entry} "ENTRYPOINT_NAME")
77 list(APPEND entrypoints_name_list ${entry_name})
80 # TODO: Remove these when they are added to the TableGen.
81 list(REMOVE_ITEM entrypoints_name_list "__assert_fail" "__errno_location")
82 list(TRANSFORM entrypoints_name_list PREPEND "-e=")
84 file(GLOB spec_files ${LIBC_SOURCE_DIR}/spec/*.td)
86 # Generate api test souce code.
89 COMMAND $<TARGET_FILE:libc-prototype-testgen> -o ${public_test}
90 ${entrypoints_name_list}
92 ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td
94 DEPENDS ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td ${spec_files}
95 libc-prototype-testgen ${TARGET_PUBLIC_HEADERS}
99 add_custom_target(libc-api-test)
101 allocator_entrypoints
102 libc.src.stdlib.malloc
103 libc.src.stdlib.calloc
104 libc.src.stdlib.realloc
105 libc.src.stdlib.aligned_alloc
108 set(api-test-entrypoints ${TARGET_LLVMLIBC_ENTRYPOINTS})
109 list(REMOVE_ITEM api-test-entrypoints ${allocator_entrypoints})
110 add_integration_test(
117 libc.startup.linux.crt1
119 ${api-test-entrypoints}
122 if(COMPILER_RESOURCE_DIR AND LLVM_LIBC_ENABLE_LINTING)
126 COMMAND $<TARGET_FILE:clang-tidy> --system-headers
127 --checks=-*,llvmlibc-restrict-system-libc-headers
128 "--extra-arg=-resource-dir=${COMPILER_RESOURCE_DIR}"
130 --warnings-as-errors=llvmlibc-*
131 "-config={CheckOptions: [{key: llvmlibc-restrict-system-libc-headers.Includes, value: '-*, linux/*, asm/*.h, asm-generic/*.h'}]}"
133 -p ${PROJECT_BINARY_DIR}
136 clang-tidy ${public_test}
138 add_dependencies(libc-api-test libc-api-test-tidy)