brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 0c6ec9f Raw
106 lines · plain
1function(add_fp_unittest name)2  cmake_parse_arguments(3    "MATH_UNITTEST"4    "NEED_MPFR;NEED_MPC;UNIT_TEST_ONLY;HERMETIC_TEST_ONLY" # Optional arguments5    "" # Single value arguments6    "LINK_LIBRARIES;DEPENDS" # Multi-value arguments7    ${ARGN}8  )9 10  if(MATH_UNITTEST_NEED_MPC)11    set(MATH_UNITTEST_NEED_MPFR TRUE)12    if(NOT LIBC_TESTS_CAN_USE_MPC)13      message(VERBOSE "Complex test ${name} will be skipped as MPC library is not available.")14      return()15    endif()16    list(APPEND MATH_UNITTEST_LINK_LIBRARIES libcMPCWrapper)17  endif()18 19  if(MATH_UNITTEST_NEED_MPFR)20    if(NOT LIBC_TESTS_CAN_USE_MPFR)21      message(VERBOSE "Math test ${name} will be skipped as MPFR library is not available.")22      return()23    endif()24  endif()25 26  if(MATH_UNITTEST_HERMETIC_TEST_ONLY)27    set(test_type HERMETIC_TEST_ONLY)28  elseif(MATH_UNITTEST_UNIT_TEST_ONLY)29    set(test_type UNIT_TEST_ONLY)30  endif()31  if(MATH_UNITTEST_NEED_MPFR)32    if(MATH_UNITTEST_HERMETIC_TEST_ONLY)33      message(FATAL_ERROR "Hermetic math test cannot require MPFR.")34    endif()35    set(test_type UNIT_TEST_ONLY)36    list(APPEND MATH_UNITTEST_LINK_LIBRARIES libcMPFRWrapper -lmpfr -lgmp)37    if(NOT(LIBC_TARGET_OS_IS_DARWIN))38      # macOS does not have libatomic.39      list(APPEND MATH_UNITTEST_LINK_LIBRARIES -latomic)40    endif()41  endif()42  list(APPEND MATH_UNITTEST_LINK_LIBRARIES LibcFPTestHelpers)43 44  set(deps libc.hdr.math_macros)45  if(MATH_UNITTEST_DEPENDS)46    list(APPEND deps ${MATH_UNITTEST_DEPENDS})47  endif()48 49  add_libc_test(50    ${name}51    ${test_type}52    LINK_LIBRARIES "${MATH_UNITTEST_LINK_LIBRARIES}"53    "${MATH_UNITTEST_UNPARSED_ARGUMENTS}"54    DEPENDS55      libc.hdr.stdint_proxy56      "${deps}"57  )58endfunction(add_fp_unittest)59 60add_subdirectory(__support)61add_subdirectory(complex)62add_subdirectory(ctype)63add_subdirectory(errno)64add_subdirectory(fenv)65add_subdirectory(math)66add_subdirectory(search)67add_subdirectory(setjmp)68add_subdirectory(stdbit)69add_subdirectory(stdfix)70add_subdirectory(stdio)71add_subdirectory(stdlib)72add_subdirectory(string)73add_subdirectory(strings)74add_subdirectory(wchar)75add_subdirectory(wctype)76add_subdirectory(time)77add_subdirectory(unistd)78 79# Depends on utilities in stdlib80add_subdirectory(inttypes)81 82if(${LIBC_TARGET_OS} STREQUAL "linux")83  add_subdirectory(fcntl)84  add_subdirectory(poll)85  add_subdirectory(sched)86  add_subdirectory(sys)87  add_subdirectory(termios)88endif()89 90if(NOT LLVM_LIBC_FULL_BUILD)91  return()92endif()93 94add_subdirectory(arpa)95add_subdirectory(assert)96add_subdirectory(compiler)97add_subdirectory(dirent)98add_subdirectory(locale)99add_subdirectory(nl_types)100add_subdirectory(signal)101add_subdirectory(spawn)102 103if(${LIBC_TARGET_OS} STREQUAL "linux")104  add_subdirectory(pthread)105endif()106