| 1 |
#===-- runtime/Float128Math/CMakeLists.txt ---------------------------------===# |
| 2 |
# |
| 3 |
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
# See https://llvm.org/LICENSE.txt for license information. |
| 5 |
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
# |
| 7 |
#===------------------------------------------------------------------------===# |
| 8 |
|
| 9 |
# FortranFloat128 implements IEEE-754 128-bit float math functions. |
| 10 |
# It is a thin wapper and it currently relies on third-party |
| 11 |
# libraries available for the target. |
| 12 |
# It is distributed as a static library only. |
| 13 |
# Fortran programs/libraries that end up linking any of the provided |
| 14 |
# will have a dependency on the third-party library that is being |
| 15 |
# used for building this FortranFloat128Math library. |
| 16 |
|
| 17 |
include(CheckLibraryExists) |
| 18 |
|
| 19 |
set(sources |
| 20 |
acos.cpp |
| 21 |
acosh.cpp |
| 22 |
asin.cpp |
| 23 |
asinh.cpp |
| 24 |
atan.cpp |
| 25 |
atan2.cpp |
| 26 |
atanh.cpp |
| 27 |
ceil.cpp |
| 28 |
complex-math.c |
| 29 |
cos.cpp |
| 30 |
cosh.cpp |
| 31 |
erf.cpp |
| 32 |
erfc.cpp |
| 33 |
exp.cpp |
| 34 |
exponent.cpp |
| 35 |
floor.cpp |
| 36 |
fma.cpp |
| 37 |
fraction.cpp |
| 38 |
hypot.cpp |
| 39 |
j0.cpp |
| 40 |
j1.cpp |
| 41 |
jn.cpp |
| 42 |
lgamma.cpp |
| 43 |
llround.cpp |
| 44 |
log.cpp |
| 45 |
log10.cpp |
| 46 |
lround.cpp |
| 47 |
mod-real.cpp |
| 48 |
modulo-real.cpp |
| 49 |
nearest.cpp |
| 50 |
norm2.cpp |
| 51 |
pow.cpp |
| 52 |
random.cpp |
| 53 |
round.cpp |
| 54 |
rrspacing.cpp |
| 55 |
scale.cpp |
| 56 |
set-exponent.cpp |
| 57 |
sin.cpp |
| 58 |
sinh.cpp |
| 59 |
spacing.cpp |
| 60 |
sqrt.cpp |
| 61 |
tan.cpp |
| 62 |
tanh.cpp |
| 63 |
tgamma.cpp |
| 64 |
trunc.cpp |
| 65 |
y0.cpp |
| 66 |
y1.cpp |
| 67 |
yn.cpp |
| 68 |
) |
| 69 |
|
| 70 |
include_directories(AFTER "${CMAKE_CURRENT_SOURCE_DIR}/..") |
| 71 |
add_library(FortranFloat128MathILib INTERFACE) |
| 72 |
|
| 73 |
if (FLANG_RUNTIME_F128_MATH_LIB) |
| 74 |
if (${FLANG_RUNTIME_F128_MATH_LIB} STREQUAL "libquadmath") |
| 75 |
check_include_file(quadmath.h FOUND_QUADMATH_HEADER) |
| 76 |
if(FOUND_QUADMATH_HEADER) |
| 77 |
add_compile_definitions(HAS_QUADMATHLIB) |
| 78 |
else() |
| 79 |
message(FATAL_ERROR |
| 80 |
"FLANG_RUNTIME_F128_MATH_LIB setting requires quadmath.h " |
| 81 |
"to be available: ${FLANG_RUNTIME_F128_MATH_LIB}" |
| 82 |
) |
| 83 |
endif() |
| 84 |
else() |
| 85 |
message(FATAL_ERROR |
| 86 |
"Unsupported third-party library for Fortran F128 math runtime: " |
| 87 |
"${FLANG_RUNTIME_F128_MATH_LIB}" |
| 88 |
) |
| 89 |
endif() |
| 90 |
|
| 91 |
add_flang_library(FortranFloat128Math STATIC INSTALL_WITH_TOOLCHAIN |
| 92 |
${sources}) |
| 93 |
|
| 94 |
if (DEFINED MSVC) |
| 95 |
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded) |
| 96 |
add_flang_library(FortranFloat128Math.static STATIC INSTALL_WITH_TOOLCHAIN |
| 97 |
${sources} |
| 98 |
) |
| 99 |
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug) |
| 100 |
add_flang_library(FortranFloat128Math.static_dbg STATIC INSTALL_WITH_TOOLCHAIN |
| 101 |
${sources} |
| 102 |
) |
| 103 |
add_dependencies(FortranFloat128Math FortranFloat128Math.static |
| 104 |
FortranFloat128Math.static_dbg |
| 105 |
) |
| 106 |
endif() |
| 107 |
elseif (HAVE_LDBL_MANT_DIG_113) |
| 108 |
# We can use 'long double' versions from libc. |
| 109 |
check_library_exists(m sinl "" FOUND_LIBM) |
| 110 |
if (FOUND_LIBM) |
| 111 |
target_compile_definitions(FortranFloat128MathILib INTERFACE |
| 112 |
HAS_LIBM |
| 113 |
) |
| 114 |
target_sources(FortranFloat128MathILib INTERFACE ${sources}) |
| 115 |
else() |
| 116 |
message(FATAL_ERROR "FortranRuntime cannot build without libm") |
| 117 |
endif() |
| 118 |
else() |
| 119 |
# We can use '__float128' version from libc, if it has them. |
| 120 |
check_library_exists(m sinf128 "" FOUND_LIBMF128) |
| 121 |
if (FOUND_LIBMF128) |
| 122 |
target_compile_definitions(FortranFloat128MathILib INTERFACE |
| 123 |
HAS_LIBMF128 |
| 124 |
) |
| 125 |
# Enable this, when math-entries.h and complex-math.h is ready. |
| 126 |
# target_sources(FortranFloat128MathILib INTERFACE ${sources}) |
| 127 |
endif() |
| 128 |
endif() |