Skip to content

Commit ca885da

Browse files
committed
Use C++17 compiler if possible
This allows using new features of C++17 conditionally. Simplify also the code which checks and sets the C++ version. Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent 7d3e132 commit ca885da

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

configure.ac

+9-17
Original file line numberDiff line numberDiff line change
@@ -350,33 +350,25 @@ dnl Turn on C++11 or newer
350350
dnl **********************
351351
352352
CPLUSPLUS=
353-
354-
AX_CHECK_COMPILE_FLAG([-std=c++11], [cplusplus11=true], [cplusplus11=false], [$WERROR])
355-
if $cplusplus11; then
356-
CPLUSPLUS=11
357-
fi
358-
359-
AX_CHECK_COMPILE_FLAG([-std=c++14], [cplusplus14=true], [cplusplus14=false], [$WERROR])
360-
if $cplusplus14; then
361-
CPLUSPLUS=14
362-
fi
353+
AX_CHECK_COMPILE_FLAG([-std=c++11], [CPLUSPLUS=11], [], [$WERROR])
354+
AX_CHECK_COMPILE_FLAG([-std=c++14], [CPLUSPLUS=14], [], [$WERROR])
355+
AX_CHECK_COMPILE_FLAG([-std=c++17], [CPLUSPLUS=17], [], [$WERROR])
356+
#AX_CHECK_COMPILE_FLAG([-std=c++20], [CPLUSPLUS=20], [], [$WERROR])
363357
364358
if test -z "$CPLUSPLUS"; then
365359
AC_MSG_ERROR([Your compiler does not have the necessary C++11 support! Cannot proceed.])
366360
fi
367361
368-
# Set C++11 or C++14 support based on platform/compiler
362+
# Set C++11, C++14 or C++17 support based on platform/compiler
369363
case "${host_os}" in
370364
cygwin*)
371365
CXXFLAGS="$CXXFLAGS -std=gnu++$CPLUSPLUS"
372366
;;
373367
*-darwin* | *-macos10*)
374-
if test "x$CLANG" = "xyes"; then
375-
CXXFLAGS="$CXXFLAGS -std=c++$CPLUSPLUS"
376-
LDFLAGS="$LDFLAGS -stdlib=libc++"
377-
else
378-
CXXFLAGS="$CXXFLAGS -std=c++$CPLUSPLUS"
379-
fi
368+
CXXFLAGS="$CXXFLAGS -std=c++$CPLUSPLUS"
369+
if test "x$CLANG" = "xyes"; then
370+
LDFLAGS="$LDFLAGS -stdlib=libc++"
371+
fi
380372
;;
381373
*)
382374
# default

0 commit comments

Comments
 (0)