From 75986db5b5a8d19ffed92b1b38d24d062c2f2d88 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Sat, 12 Aug 2017 11:37:41 -0500 Subject: [PATCH] CMake: In case of C++14 support, check whether std::max/min support constexpr --- cmake/checks/check_01_cxx_features.cmake | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/cmake/checks/check_01_cxx_features.cmake b/cmake/checks/check_01_cxx_features.cmake index d1dc5b7914..877438eaf4 100644 --- a/cmake/checks/check_01_cxx_features.cmake +++ b/cmake/checks/check_01_cxx_features.cmake @@ -49,6 +49,7 @@ IF(DEFINED DEAL_II_WITH_CXX14 AND NOT DEAL_II_WITH_CXX14) SET(DEAL_II_WITH_CXX17 OFF CACHE STRING "" FORCE) ENDIF() +# # Check the user supplied DEAL_II_CXX_VERSION_FLAG # @@ -183,6 +184,22 @@ IF(NOT DEFINED DEAL_II_WITH_CXX14 OR DEAL_II_WITH_CXX14) " DEAL_II_HAVE_CXX14_MAKE_UNIQUE) + # + # This test checks constexpr std::max/min support. Unfortunately, + # gcc-4.9 does claim to support C++14 but fails to provide a constexpr + # compatible std::max/min. Disable C++14 support in this case. + # + CHECK_CXX_SOURCE_COMPILES( + " + #include + int main() + { + constexpr int max = std::max(0,1); + } + " + DEAL_II_HAVE_CXX14_CONSTEXPR_STDMAXMIN) + + # # Clang-3.5* or older, bail out with a spurious error message in case # of an undeduced auto return type. @@ -207,7 +224,8 @@ IF(NOT DEFINED DEAL_II_WITH_CXX14 OR DEAL_II_WITH_CXX14) ENDIF() IF( DEAL_II_HAVE_CXX14_MAKE_UNIQUE AND - DEAL_II_HAVE_CXX14_CLANGAUTODEBUG_BUG_OK ) + DEAL_II_HAVE_CXX14_CLANGAUTODEBUG_BUG_OK AND + DEAL_II_HAVE_CXX14_CONSTEXPR_STDMAXMIN) SET(DEAL_II_HAVE_CXX14 TRUE) ELSE() IF(NOT _user_provided_cxx_version_flag) -- 2.39.5