Skip to content

Commit 469f953

Browse files
committed
Problem: test for C++11 (so g++4.9) is unavoidable
Solution: make the check for std::regex (assuming it means sufficient level of C++11 in GCC) optional with --enable-gcc-std-regex=no and by default enabled. A build with this option set to 'no' should compile, but the result would not necessarily function (gcc-4.8 and earlier could include the API routines for supporting the standard, but not really implement it). Primary intended use-case: If Travis CI tests of some projects "use" a project that by itself requires C++11, but do not really use this aspect of it in their own unit-tests, this is sufficient for "trusty" machines with older GCC. In this case, the "<use>" tag for such project can be amended with <add_config_opts>--enable-gcc-std-regex=no</add_config_opts> tags to avoid configure-time failures in Travis CI builds of the whole dependency chain (unpackaged mode). Signed-off-by: Jim Klimov <[email protected]>
1 parent 25e6b12 commit 469f953

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

zproject_autotools.gsl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,16 @@ AS_IF([test "x$enable_Werror" = "xyes" || test "x$enable_Werror" = "xauto"],
12381238
# One of big missing features in gcc-4.8 was std::regex support fixed in 4.9
12391239
# Testing code from https://stackoverflow.com/a/41186162/4715872
12401240
# caveats apply (use of unguaranteed private macros)
1241+
AC_ARG_ENABLE([gcc-std-regex],
1242+
AS_HELP_STRING([--enable-gcc-std-regex],
1243+
[Check for std::regex support if compiler is GCC, assuming it means satisfactory level of C++11 there [default=yes]]),
1244+
[enable_gcc_std_regex=$enableval],
1245+
[enable_gcc_std_regex=$defaultval])
1246+
1247+
AM_CONDITIONAL([ENABLE_GCC_STD_REGEX], [test x$enable_gcc_std_regex != xno])
1248+
12411249
AS_IF([test -n "$CXX"],[AS_IF([$CXX --version 2>&1 | grep 'Free Software Foundation' > /dev/null && test "x$GCC" = "xyes"],
1250+
[AS_IF([test "x$enable_gcc_std_regex" = "xyes" || test "x$enable_gcc_std_regex" = "xauto"],
12421251
[AC_MSG_CHECKING([for GNU C++11 support level expected by gcc-4.9 release or newer])
12431252
CXXFLAGS="$CXXFLAGS --std=c++11"
12441253
AC_LANG_PUSH([C++])
@@ -1272,6 +1281,9 @@ int main() {
12721281
], AC_MSG_RESULT([ok]), AC_MSG_ERROR([test for std::regex failed]) )
12731282
AC_LANG_POP([C++])
12741283
]
1284+
,[AC_MSG_WARN([Not checking for GNU C++11 support level expected by gcc-4.9 release or newer, due to explicit configure option])
1285+
AC_MSG_WARN([YOU ARE AT RISK OF SOMETHING NOT WORKING WITH THIS BUILD OF THE CODEBASE])]
1286+
)]
12751287
)])
12761288

12771289
.endif

0 commit comments

Comments
 (0)