From 12bb88871e3cc4f52b3bc488ddc73389a7ac3b55 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 20 Oct 2021 15:18:00 +0200 Subject: [PATCH] :alembic: do not use too old compilers with C++17 --- include/nlohmann/detail/macro_scope.hpp | 2 +- single_include/nlohmann/json.hpp | 2 +- test/CMakeLists.txt | 4 ++++ test/src/unit-regression2.cpp | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index 22c0ea525..e113ea573 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -54,7 +54,7 @@ #endif // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ - #if __MINGW32__ && __GNUC__ == 8 + #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 #undef JSON_STD_FILESYSTEM_EXPERIMENTAL #endif #endif diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 7e758f05f..4cb0056e5 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2342,7 +2342,7 @@ using is_detected_convertible = #endif // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ - #if __MINGW32__ && __GNUC__ == 8 + #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 #undef JSON_STD_FILESYSTEM_EXPERIMENTAL #endif #endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5f681e5d0..0ab021051 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -58,6 +58,10 @@ foreach(feature ${CMAKE_CXX_COMPILE_FEATURES}) set(compiler_supports_cpp_17 TRUE) endif() endforeach() +# Clang only supports C++17 starting from Clang 5.0 +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + unset(compiler_supports_cpp_17) +endif() file(GLOB files src/unit-*.cpp) diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index fb8b268c6..292f5f04a 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -64,7 +64,7 @@ using ordered_json = nlohmann::ordered_json; #define JSON_STD_FILESYSTEM_EXPERIMENTAL 0 // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ - #if __MINGW32__ && __GNUC__ == 8 + #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 #undef JSON_STD_FILESYSTEM_EXPERIMENTAL #endif #endif