xref: /llvm-project/libc/utils/MPFRWrapper/CMakeLists.txt (revision a080498c92e4c00f099dab1a3d5dac48f14b7492)
17f37b34dSShourya Goelif(LIBC_TESTS_CAN_USE_MPFR OR LIBC_TESTS_CAN_USE_MPC)
27f37b34dSShourya Goel  add_library(libcMPCommon STATIC
37f37b34dSShourya Goel    MPCommon.cpp
47f37b34dSShourya Goel    MPCommon.h
5ae3b59e6SMichael Jones    mpfr_inc.h
65fedf7f4SSiva Chandra Reddy  )
780cf21daSlntue  _get_common_test_compile_options(compile_options "" "")
8fc7a8936Slntue  # mpfr/gmp headers do not work with -ffreestanding flag.
9fc7a8936Slntue  list(REMOVE_ITEM compile_options "-ffreestanding")
107f37b34dSShourya Goel  target_compile_options(libcMPCommon PRIVATE -O3 ${compile_options})
11bf0ded80SMichael Jones  add_dependencies(
127f37b34dSShourya Goel    libcMPCommon
137f37b34dSShourya Goel    libc.src.__support.CPP.string
14bf0ded80SMichael Jones    libc.src.__support.CPP.string_view
15bf0ded80SMichael Jones    libc.src.__support.CPP.type_traits
16127349fcSOverMighty    libc.src.__support.FPUtil.cast
179ac66f06SMichael Jones    libc.src.__support.FPUtil.fp_bits
187f37b34dSShourya Goel  )
19*a080498cSlntue  if(EXISTS ${LLVM_LIBC_MPFR_INSTALL_PATH})
20*a080498cSlntue    target_include_directories(libcMPCommon PUBLIC ${LLVM_LIBC_MPFR_INSTALL_PATH}/include)
21*a080498cSlntue    target_link_directories(libcMPCommon PUBLIC ${LLVM_LIBC_MPFR_INSTALL_PATH}/lib)
22*a080498cSlntue  endif()
237f37b34dSShourya Goel  target_include_directories(libcMPCommon PUBLIC ${LIBC_SOURCE_DIR})
247f37b34dSShourya Goel  target_link_libraries(libcMPCommon PUBLIC LibcFPTestHelpers.unit mpfr gmp)
257f37b34dSShourya Goelelseif(NOT LIBC_TARGET_OS_IS_GPU AND NOT LLVM_LIBC_FULL_BUILD)
267f37b34dSShourya Goel  message(WARNING "Math tests using MPFR will be skipped.")
277f37b34dSShourya Goelendif()
287f37b34dSShourya Goel
297f37b34dSShourya Goelif(LIBC_TESTS_CAN_USE_MPFR)
307f37b34dSShourya Goel  add_library(libcMPFRWrapper STATIC
317f37b34dSShourya Goel    MPFRUtils.cpp
327f37b34dSShourya Goel    MPFRUtils.h
337f37b34dSShourya Goel  )
347f37b34dSShourya Goel  _get_common_test_compile_options(compile_options "" "")
35839cdb58SShourya Goel  # mpfr/gmp headers do not work with -ffreestanding flag.
36839cdb58SShourya Goel  list(REMOVE_ITEM compile_options "-ffreestanding")
377f37b34dSShourya Goel  target_compile_options(libcMPFRWrapper PRIVATE -O3 ${compile_options})
387f37b34dSShourya Goel  add_dependencies(
397f37b34dSShourya Goel    libcMPFRWrapper
407f37b34dSShourya Goel    libcMPCommon
417f37b34dSShourya Goel    libc.src.__support.CPP.array
427f37b34dSShourya Goel    libc.src.__support.CPP.stringstream
437f37b34dSShourya Goel    libc.src.__support.FPUtil.fp_bits
4437458f66STue Ly    libc.src.__support.FPUtil.fpbits_str
454dc205f0SSiva Chandra Reddy    LibcTest.unit
46bf0ded80SMichael Jones  )
478baa87d9SHedin Garca  if(EXISTS ${LLVM_LIBC_MPFR_INSTALL_PATH})
488baa87d9SHedin Garca    target_include_directories(libcMPFRWrapper PUBLIC ${LLVM_LIBC_MPFR_INSTALL_PATH}/include)
498baa87d9SHedin Garca    target_link_directories(libcMPFRWrapper PUBLIC ${LLVM_LIBC_MPFR_INSTALL_PATH}/lib)
508baa87d9SHedin Garca  endif()
5180cf21daSlntue  target_include_directories(libcMPFRWrapper PUBLIC ${LIBC_SOURCE_DIR})
527f37b34dSShourya Goel  target_link_libraries(libcMPFRWrapper PUBLIC libcMPCommon LibcFPTestHelpers.unit LibcTest.unit)
5354c24ec9SSchrodinger ZHU Yifanelseif(NOT LIBC_TARGET_OS_IS_GPU AND NOT LLVM_LIBC_FULL_BUILD)
545fedf7f4SSiva Chandra Reddy  message(WARNING "Math tests using MPFR will be skipped.")
555fedf7f4SSiva Chandra Reddyendif()
56