xref: /llvm-project/libc/utils/MPFRWrapper/CMakeLists.txt (revision a080498c92e4c00f099dab1a3d5dac48f14b7492)
1if(LIBC_TESTS_CAN_USE_MPFR OR LIBC_TESTS_CAN_USE_MPC)
2  add_library(libcMPCommon STATIC
3    MPCommon.cpp
4    MPCommon.h
5    mpfr_inc.h
6  )
7  _get_common_test_compile_options(compile_options "" "")
8  # mpfr/gmp headers do not work with -ffreestanding flag.
9  list(REMOVE_ITEM compile_options "-ffreestanding")
10  target_compile_options(libcMPCommon PRIVATE -O3 ${compile_options})
11  add_dependencies(
12    libcMPCommon
13    libc.src.__support.CPP.string
14    libc.src.__support.CPP.string_view
15    libc.src.__support.CPP.type_traits
16    libc.src.__support.FPUtil.cast
17    libc.src.__support.FPUtil.fp_bits
18  )
19  if(EXISTS ${LLVM_LIBC_MPFR_INSTALL_PATH})
20    target_include_directories(libcMPCommon PUBLIC ${LLVM_LIBC_MPFR_INSTALL_PATH}/include)
21    target_link_directories(libcMPCommon PUBLIC ${LLVM_LIBC_MPFR_INSTALL_PATH}/lib)
22  endif()
23  target_include_directories(libcMPCommon PUBLIC ${LIBC_SOURCE_DIR})
24  target_link_libraries(libcMPCommon PUBLIC LibcFPTestHelpers.unit mpfr gmp)
25elseif(NOT LIBC_TARGET_OS_IS_GPU AND NOT LLVM_LIBC_FULL_BUILD)
26  message(WARNING "Math tests using MPFR will be skipped.")
27endif()
28
29if(LIBC_TESTS_CAN_USE_MPFR)
30  add_library(libcMPFRWrapper STATIC
31    MPFRUtils.cpp
32    MPFRUtils.h
33  )
34  _get_common_test_compile_options(compile_options "" "")
35  # mpfr/gmp headers do not work with -ffreestanding flag.
36  list(REMOVE_ITEM compile_options "-ffreestanding")
37  target_compile_options(libcMPFRWrapper PRIVATE -O3 ${compile_options})
38  add_dependencies(
39    libcMPFRWrapper
40    libcMPCommon
41    libc.src.__support.CPP.array
42    libc.src.__support.CPP.stringstream
43    libc.src.__support.FPUtil.fp_bits
44    libc.src.__support.FPUtil.fpbits_str
45    LibcTest.unit
46  )
47  if(EXISTS ${LLVM_LIBC_MPFR_INSTALL_PATH})
48    target_include_directories(libcMPFRWrapper PUBLIC ${LLVM_LIBC_MPFR_INSTALL_PATH}/include)
49    target_link_directories(libcMPFRWrapper PUBLIC ${LLVM_LIBC_MPFR_INSTALL_PATH}/lib)
50  endif()
51  target_include_directories(libcMPFRWrapper PUBLIC ${LIBC_SOURCE_DIR})
52  target_link_libraries(libcMPFRWrapper PUBLIC libcMPCommon LibcFPTestHelpers.unit LibcTest.unit)
53elseif(NOT LIBC_TARGET_OS_IS_GPU AND NOT LLVM_LIBC_FULL_BUILD)
54  message(WARNING "Math tests using MPFR will be skipped.")
55endif()
56