cmlib/CMLibHighPrecisionMath.cmake

41 lines
886 B
CMake
Raw Normal View History

function(enable_high_precision_math)
set(options QUAD MPFR)
set(oneValueArgs)
set(multiValueArgs)
2021-07-06 01:54:20 +00:00
cmake_parse_arguments(_PREFIX "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
2021-07-06 01:54:20 +00:00
if(_PREFIX_MPFR AND _PREFIX_QUAD)
message(FATAL_ERROR "Mutually exclusive options QUAD and MPFR")
endif()
2021-07-06 01:54:20 +00:00
if(_PREFIX_MPFR)
find_package(MPFR)
if(MPFR_FOUND)
find_package(MPFRCppThirdparty)
endif()
return()
endif()
2021-07-06 01:54:20 +00:00
if(_PREFIX_QUAD)
find_package(Quadmath)
if(QUADMATH_FOUND)
add_definitions(-DHAVE_QUADMATH=1)
endif()
return()
endif()
# Default
find_package(Quadmath)
if(QUADMATH_FOUND)
add_definitions(-DHAVE_QUADMATH=1)
else()
find_package(MPFR)
if(MPFR_FOUND)
find_package(MPFRCppThirdparty)
else()
message(FATAL_ERROR "Nor Quadmath, nor MPFR found.")
endif()
endif()
endfunction()