diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 1d0181ce9e29..70085f5c6778 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -23,6 +23,11 @@ jobs: std: 14 install: sudo apt install g++-8 os: ubuntu-18.04 + - cxx: g++-8 + build_type: Debug + std: 17 + install: sudo apt install g++-8 + os: ubuntu-18.04 - cxx: g++-10 build_type: Debug std: 17 @@ -32,6 +37,12 @@ jobs: std: 20 os: ubuntu-20.04 install: sudo apt install g++-11 + - cxx: clang++-8 + build_type: Debug + std: 17 + cxxflags: -stdlib=libc++ + os: ubuntu-18.04 + install: sudo apt install clang-8 libc++-8-dev libc++abi-8-dev - cxx: clang++-9 build_type: Debug fuzz: -DFMT_FUZZ=ON -DFMT_FUZZ_LINKMAIN=ON diff --git a/include/fmt/std.h b/include/fmt/std.h index ccf376a26e8d..41d2b2838b6d 100644 --- a/include/fmt/std.h +++ b/include/fmt/std.h @@ -17,10 +17,17 @@ #if FMT_HAS_INCLUDE() # include #endif +// Checking FMT_CPLUSPLUS for warning suppression in MSVC. +#if FMT_CPLUSPLUS >= 201703L +# if FMT_HAS_INCLUDE() +# include +# endif +# if FMT_HAS_INCLUDE() +# include +# endif +#endif #ifdef __cpp_lib_filesystem -# include - FMT_BEGIN_NAMESPACE namespace detail { @@ -71,8 +78,6 @@ struct formatter : basic_ostream_formatter {}; FMT_END_NAMESPACE #ifdef __cpp_lib_variant -# include - FMT_BEGIN_NAMESPACE template struct formatter { template diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6cdb7ac42fa0..5ac1962916c5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -78,6 +78,14 @@ add_fmt_test(printf-test) add_fmt_test(ranges-test ranges-odr-test.cc) add_fmt_test(scan-test) add_fmt_test(std-test) +try_compile(compile_result_unused + ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_LIST_DIR}/detect-stdfs.cc + OUTPUT_VARIABLE RAWOUTPUT) +string(REGEX REPLACE ".*libfound \"([^\"]*)\".*" "\\1" STDLIBFS "${RAWOUTPUT}") +if (STDLIBFS) + target_link_libraries(std-test ${STDLIBFS}) +endif () add_fmt_test(unicode-test HEADER_ONLY) if (MSVC) target_compile_options(unicode-test PRIVATE /utf-8) diff --git a/test/detect-stdfs.cc b/test/detect-stdfs.cc new file mode 100644 index 000000000000..2dc6653830ab --- /dev/null +++ b/test/detect-stdfs.cc @@ -0,0 +1,18 @@ +// Formatting library for C++ - tests of formatters for standard library types +// +// Copyright (c) 2012 - present, Victor Zverovich +// All rights reserved. +// +// For the license information refer to format.h. + +#include // _GLIBCXX_RELEASE & _LIBCPP_VERSION + +#if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE == 8 +# error libfound "stdc++fs" +#elif !defined(__apple_build_version__) && defined(_LIBCPP_VERSION) && \ + _LIBCPP_VERSION >= 7000 && _LIBCPP_VERSION < 9000 +# error libfound "c++fs" +#else +// none if std::filesystem does not require additional libraries +# error libfound "" +#endif