diff --git a/CMakeLists.txt b/CMakeLists.txt index e15718b6..bbf4e46c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -351,6 +351,33 @@ if (NOT ${HAVE_STD_ISNAN}) message(FATAL_ERROR "Your compiler lacks C++11 std::isnan, please update it") endif() +# Check if the implementation in the C++ standard library is usable. +# This is necessary because g++ 4.8 lies about its C++11 compliance: its +# is utterly unusable, cf. [1]. +# The big preprocessor test essentially comes from [2], and gcc upstream devs +# appear to back it (see comments following [2], as well as [3]). +# +# [1] https://stackoverflow.com/a/12665408/4756009 +# [2] https://stackoverflow.com/a/41186162/4756009 +# [3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78905 +check_cxx_source_compiles( + "#include + #include + +int main() { + #if __cplusplus >= 201103L && \ + (!defined(__GLIBCXX__) || \ + (__cplusplus >= 201402L) || \ + defined(_GLIBCXX_REGEX_DFS_QUANTIFIERS_LIMIT) || \ + defined(_GLIBCXX_REGEX_STATE_LIMIT) || \ + (defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE > 4)) + return EXIT_SUCCESS; + #else + nullptr = void; // intentionally trigger a compilation error + #endif +}" + HAVE_WORKING_STD_REGEX) + if(CMAKE_COMPILER_IS_GNUCXX) set(WARNING_FLAGS_CXX "-Wall -fPIC") set(WARNING_FLAGS_C "-Wall -fPIC") diff --git a/simgear/simgear_config_cmake.h.in b/simgear/simgear_config_cmake.h.in index ba28e761..0282aca1 100644 --- a/simgear/simgear_config_cmake.h.in +++ b/simgear/simgear_config_cmake.h.in @@ -11,6 +11,7 @@ #cmakedefine HAVE_TIMEGM #cmakedefine HAVE_STD_ISNAN +#cmakedefine HAVE_WORKING_STD_REGEX #cmakedefine HAVE_WINDOWS_H #cmakedefine HAVE_MKDTEMP #cmakedefine HAVE_AL_EXT_H