@@ -331,46 +331,42 @@ AC_COMPILE_IFELSE(
331
331
332
332
AC_MSG_RESULT([$CLANG])
333
333
334
- dnl ********************
335
- dnl turn on c ++11
336
- dnl ********************
334
+ dnl **********************
335
+ dnl Turn on C ++11 or newer
336
+ dnl **********************
337
337
338
- OLD_CXXFLAGS=$CXXFLAGS
339
- AC_MSG_CHECKING([whether compiler supports C++11])
340
- CXXFLAGS="$CXXFLAGS -std=c++11"
341
- AC_COMPILE_IFELSE(
342
- [
343
- AC_LANG_SOURCE([[
344
- #if (__cplusplus < 201103L)
345
- #error C++ 11 is unsupported
346
- #endif
347
- ]])
348
- ], [
349
- AC_MSG_RESULT(yes)
350
- ],
351
- [
352
- AC_MSG_RESULT(no)
353
- AC_MSG_ERROR([Your compiler does not have the necessary c++11 support! Cannot proceed.])
354
- ])
355
- CXXFLAGS="$OLD_CXXFLAGS"
356
-
357
-
358
- # set c++11 support based on platform/compiler
338
+ CPLUSPLUS=
339
+
340
+ AX_CHECK_COMPILE_FLAG([-std=c++11], [cplusplus11=true], [cplusplus11=false])
341
+ if $cplusplus11; then
342
+ CPLUSPLUS=11
343
+ fi
344
+
345
+ AX_CHECK_COMPILE_FLAG([-std=c++14], [cplusplus14=true], [cplusplus14=false])
346
+ if $cplusplus14; then
347
+ CPLUSPLUS=14
348
+ fi
349
+
350
+ if test -z "$CPLUSPLUS"; then
351
+ AC_MSG_ERROR([Your compiler does not have the necessary C++11 support! Cannot proceed.])
352
+ fi
353
+
354
+ # Set C++11 or C++14 support based on platform/compiler
359
355
case "${host_os}" in
360
356
cygwin*)
361
- CXXFLAGS="$CXXFLAGS -std=gnu++11 "
357
+ CXXFLAGS="$CXXFLAGS -std=gnu++$CPLUSPLUS "
362
358
;;
363
359
*-darwin* | *-macos10*)
364
360
if test "x$CLANG" = "xyes"; then
365
- CXXFLAGS="$CXXFLAGS -std=c++11 "
361
+ CXXFLAGS="$CXXFLAGS -std=c++$CPLUSPLUS "
366
362
LDFLAGS="$LDFLAGS -stdlib=libc++"
367
363
else
368
- CXXFLAGS="$CXXFLAGS -std=c++11 "
364
+ CXXFLAGS="$CXXFLAGS -std=c++$CPLUSPLUS "
369
365
fi
370
366
;;
371
367
*)
372
368
# default
373
- CXXFLAGS="$CXXFLAGS -std=c++11 "
369
+ CXXFLAGS="$CXXFLAGS -std=c++$CPLUSPLUS "
374
370
;;
375
371
esac
376
372
0 commit comments