From 7c22ac6b82913969e874612ee519d6f4eea0ed09 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Tue, 6 Jul 2021 04:40:23 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE=D0=B4=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2=D1=8B=D1=87=D0=B8=D1=81=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B9=20=D1=81=20=D0=B2=D1=8B=D1=81=D0=BE?= =?UTF-8?q?=D0=BA=D0=BE=D0=B9=20=D1=82=D0=BE=D1=87=D0=BD=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D1=8C=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMLibCommon.cmake | 1 + CMLibHighPrecisionMath.cmake | 40 ++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 CMLibHighPrecisionMath.cmake diff --git a/CMLibCommon.cmake b/CMLibCommon.cmake index 53d088d..8c5a77b 100644 --- a/CMLibCommon.cmake +++ b/CMLibCommon.cmake @@ -30,6 +30,7 @@ include(CMLibLSBInfo) include(CMLibCompiler) include(CMLibCompilerFlags) include(CMLibDistCC) +include(CMLibHighPrecisionMath) include(CMLibGenerateCompilerFeaturesHPP) include(CMLibFlagRemove) include(CMLibCotire) diff --git a/CMLibHighPrecisionMath.cmake b/CMLibHighPrecisionMath.cmake new file mode 100644 index 0000000..3204f60 --- /dev/null +++ b/CMLibHighPrecisionMath.cmake @@ -0,0 +1,40 @@ +function(enable_high_precision_math) + set(options QUAD MPFR) + set(oneValueArgs) + set(multiValueArgs) + + cmake_parse_arguments(_PKG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(MPFR AND QUAD) + message(FATAL_ERROR "Mutually exclusive options QUAD and MPFR") + endif() + + if(MPFR) + find_package(MPFR) + if(MPFR_FOUND) + find_package(MPFRCppThirdparty) + endif() + return() + endif() + + if(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()