From: Gerhard Sittig Date: Mon, 21 Nov 2022 17:50:18 +0000 (+0100) Subject: configure.ac: check for highest available C++17/C++14/C++11 standard X-Git-Url: http://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=cbcc060d9409585ca237706896e9a8d21fa5b376 configure.ac: check for highest available C++17/C++14/C++11 standard There are external libraries (boost, glibmm) as well as platforms (Mac OSX 12) which "require" C++ language standards above 11. Detect the highest available standard which is supported by the compiler. Use a "have modern C++" variable to improve robustness and readability of the C++ language standard check. --- diff --git a/configure.ac b/configure.ac index 5c480818..f36a3b24 100644 --- a/configure.ac +++ b/configure.ac @@ -401,9 +401,23 @@ AC_ARG_ENABLE([java], sr_cxx_missing= -# Check if the C++ compiler supports the C++11 standard. -AX_CXX_COMPILE_STDCXX([11], [noext], [optional]) -AS_IF([test "x$HAVE_CXX11" != x1], +# Check if the C++ compiler supports at least the C++11 standard. +# Get the highest of the available C++17/C++14/C++11 standards. +# This transparently amends CXXFLAGS to pick the detected standard. +HAVE_MODERN_CXX= +AS_IF([test "x$HAVE_MODERN_CXX" = x], + [AX_CXX_COMPILE_STDCXX([17], [noext], [optional])]) +AS_IF([test "x$HAVE_CXX17" = x1], + [HAVE_MODERN_CXX=yes]) +AS_IF([test "x$HAVE_MODERN_CXX" = x], + [AX_CXX_COMPILE_STDCXX([14], [noext], [optional])]) +AS_IF([test "x$HAVE_CXX14" = x1], + [HAVE_MODERN_CXX=yes]) +AS_IF([test "x$HAVE_MODERN_CXX" = x], + [AX_CXX_COMPILE_STDCXX([11], [noext], [optional])]) +AS_IF([test "x$HAVE_CXX11" = x1], + [HAVE_MODERN_CXX=yes]) +AS_IF([test "x$HAVE_MODERN_CXX" = x], [SR_APPEND([sr_cxx_missing], [', '], ['C++11'])]) # The C++ bindings need glibmm.