diff --git a/CMakeLists.txt b/CMakeLists.txt index 61af59c9..2b29ed8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,6 +128,13 @@ endif () # add_definitions(-DFMT_USE_DELETED_FUNCTIONS=1) #endif () +#check_cxx_source_compiles(" +# static_assert(true, \"\"); +# int main(){}" FMT_STATIC_ASSERT) +#if (FMT_STATIC_ASSERT) +# add_definitions(-DFMT_USE_STATIC_ASSERT=1) +#endif () + # GTest doesn't detect with clang. if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") target_compile_definitions(gmock PUBLIC GTEST_USE_OWN_TR1_TUPLE=1) diff --git a/posix.h b/posix.h index 0f31f601..c8075cfb 100644 --- a/posix.h +++ b/posix.h @@ -68,7 +68,8 @@ # define FMT_UNUSED #endif -#if FMT_USE_STATIC_ASSERT +#if FMT_USE_STATIC_ASSERT || FMT_HAS_CPP_ATTRIBUTE(cxx_static_assert) || \ + (FMT_GCC_VERSION >= 403 && __cplusplus >= 201103) || _MSC_VER >= 1600 # define FMT_STATIC_ASSERT(cond, message) static_assert(cond, message) #else # define FMT_CONCAT_(a, b) FMT_CONCAT(a, b)