From d6701acbcea7b7f762385affbab9ea245a4557d4 Mon Sep 17 00:00:00 2001 From: David Wells Date: Mon, 6 Aug 2018 23:02:10 -0400 Subject: [PATCH] Make C++17 support independent of the special math functions. Clang does not yet have these, but supports a large subset of C++17. Since these are a library feature its easy enough to just fall back to boost. --- cmake/checks/check_01_cxx_features.cmake | 37 ++++++++++++++---------- include/deal.II/base/config.h.in | 1 + include/deal.II/base/std_cxx17/cmath.h | 2 +- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/cmake/checks/check_01_cxx_features.cmake b/cmake/checks/check_01_cxx_features.cmake index 32d61d3883..2236748438 100644 --- a/cmake/checks/check_01_cxx_features.cmake +++ b/cmake/checks/check_01_cxx_features.cmake @@ -21,7 +21,9 @@ # DEAL_II_WITH_CXX14 # DEAL_II_WITH_CXX17 # +# DEAL_II_HAVE_ATTRIBUTE_FALLTHROUGH # DEAL_II_HAVE_CXX11_IS_TRIVIALLY_COPYABLE +# DEAL_II_HAVE_CXX17_SPECIAL_MATH_FUNCTIONS # DEAL_II_HAVE_FP_EXCEPTIONS # DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS # @@ -176,22 +178,6 @@ IF(NOT DEFINED DEAL_II_WITH_CXX17 OR DEAL_II_WITH_CXX17) " DEAL_II_HAVE_CXX17_IF_CONSTEXPR) - # - # Not all compilers with C++17 support include the new special math functions: - # - CHECK_CXX_SOURCE_COMPILES( - " - #include - - int main() - { - std::cyl_bessel_j(1.0, 1.0); - std::cyl_bessel_jf(1.0f, 1.0f); - std::cyl_bessel_jl(1.0, 1.0); - } - " - DEAL_II_HAVE_CXX17_SPECIAL_MATH_FUNCTIONS) - # # Some compilers treat lambdas as constexpr functions when compiling # with C++17 support even if they don't fulfill all the constexpr @@ -567,6 +553,7 @@ UNSET_IF_CHANGED(CHECK_CXX_FEATURES_FLAGS_SAVED "${CMAKE_REQUIRED_FLAGS}${DEAL_II_CXX_VERSION_FLAG}${DEAL_II_WITH_CXX14}${DEAL_II_WITH_CXX17}" DEAL_II_HAVE_ATTRIBUTE_FALLTHROUGH DEAL_II_HAVE_CXX11_IS_TRIVIALLY_COPYABLE + DEAL_II_HAVE_CXX17_SPECIAL_MATH_FUNCTIONS DEAL_II_HAVE_FP_EXCEPTIONS DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS ) @@ -682,4 +669,22 @@ CHECK_CXX_SOURCE_COMPILES( " DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS) +# +# Not all compilers with C++17 support include the new special math +# functions. Check this separately so that we can use C++17 compilers that don't +# support it. +# +CHECK_CXX_SOURCE_COMPILES( + " + #include + + int main() + { + std::cyl_bessel_j(1.0, 1.0); + std::cyl_bessel_jf(1.0f, 1.0f); + std::cyl_bessel_jl(1.0, 1.0); + } + " + DEAL_II_HAVE_CXX17_SPECIAL_MATH_FUNCTIONS) + RESET_CMAKE_REQUIRED() diff --git a/include/deal.II/base/config.h.in b/include/deal.II/base/config.h.in index 14d4a0c61f..2aaa907e5b 100644 --- a/include/deal.II/base/config.h.in +++ b/include/deal.II/base/config.h.in @@ -115,6 +115,7 @@ */ #cmakedefine DEAL_II_HAVE_CXX11_IS_TRIVIALLY_COPYABLE +#cmakedefine DEAL_II_HAVE_CXX17_SPECIAL_MATH_FUNCTIONS #cmakedefine DEAL_II_HAVE_FP_EXCEPTIONS #cmakedefine DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS #cmakedefine DEAL_II_FALLTHROUGH @DEAL_II_FALLTHROUGH@ diff --git a/include/deal.II/base/std_cxx17/cmath.h b/include/deal.II/base/std_cxx17/cmath.h index 1245a0be17..394a2ac814 100644 --- a/include/deal.II/base/std_cxx17/cmath.h +++ b/include/deal.II/base/std_cxx17/cmath.h @@ -26,7 +26,7 @@ DEAL_II_NAMESPACE_OPEN namespace std_cxx17 { -#ifndef DEAL_II_WITH_CXX17 +#ifdef DEAL_II_HAVE_CXX17_SPECIAL_MATH_FUNCTIONS double (&cyl_bessel_j)(double, double) = boost::math::cyl_bessel_j; float (&cyl_bessel_jf)(float, -- 2.39.5