diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 14b54348a..52e753436 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -146,6 +146,9 @@ jobs: - uses: actions/checkout@v3 - name: Get latest CMake and ninja uses: lukka/get-cmake@latest + - name: Set env FORCE_STDCPPFS_FLAG for clang 7 / 8 / 9 / 10 + run: echo "JSON_FORCED_GLOBAL_COMPILE_OPTIONS=-DJSON_HAS_FILESYSTEM=0;-DJSON_HAS_EXPERIMENTAL_FILESYSTEM=0" >> "$GITHUB_ENV" + if: ${{ matrix.compiler == '7' || matrix.compiler == '8' || matrix.compiler == '9' || matrix.compiler == '10' }} - name: Run CMake run: cmake -S . -B build -DJSON_CI=On - name: Build diff --git a/cmake/ci.cmake b/cmake/ci.cmake index f0b09f6d3..d07ab920c 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -901,12 +901,7 @@ add_custom_target(ci_cmake_flags foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 g++-11 clang++-3.5 clang++-3.6 clang++-3.7 clang++-3.8 clang++-3.9 clang++-4.0 clang++-5.0 clang++-6.0 clang++-7 clang++-8 clang++-9 clang++-10 clang++-11 clang++-12 clang++-13 clang++-14) find_program(COMPILER_TOOL NAMES ${COMPILER}) if (COMPILER_TOOL) - if ("${COMPILER}" STREQUAL "clang++-9") - # fix for https://github.com/nlohmann/json/pull/3101#issuecomment-998788786 / https://stackoverflow.com/a/64051725/266378 - set(ADDITIONAL_FLAGS "-DCMAKE_CXX_FLAGS=--gcc-toolchain=/root/gcc/9") - else() - unset(ADDITIONAL_FLAGS) - endif() + unset(ADDITIONAL_FLAGS) add_custom_target(ci_test_compiler_${COMPILER} COMMAND CXX=${COMPILER} ${CMAKE_COMMAND} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1afb000ae..3b9ae4d91 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,6 +6,15 @@ option(JSON_FastTests "Skip expensive/slow tests." OFF) set(JSON_32bitTest AUTO CACHE STRING "Enable the 32bit unit test (ON/OFF/AUTO/ONLY).") set(JSON_TestStandards "" CACHE STRING "The list of standards to test explicitly.") +# using an env var, since this will also affect targets executing cmake (such as "ci_test_compiler_default") +set(JSON_FORCED_GLOBAL_COMPILE_OPTIONS $ENV{JSON_FORCED_GLOBAL_COMPILE_OPTIONS}) +if (NOT "" STREQUAL "$ENV{JSON_FORCED_GLOBAL_COMPILE_OPTIONS}") + add_compile_options($ENV{JSON_FORCED_GLOBAL_COMPILE_OPTIONS}) +endif() +if (NOT "" STREQUAL "$ENV{JSON_FORCED_GLOBAL_LINK_OPTIONS}") + add_link_options($ENV{JSON_FORCED_GLOBAL_LINK_OPTIONS}) +endif() + include(test) ############################################################################# diff --git a/tests/src/unit-regression2.cpp b/tests/src/unit-regression2.cpp index 308ceeef9..2bb9b32e5 100644 --- a/tests/src/unit-regression2.cpp +++ b/tests/src/unit-regression2.cpp @@ -37,7 +37,9 @@ using ordered_json = nlohmann::ordered_json; #endif #ifdef JSON_HAS_CPP_20 - #include + #if __has_include() + #include + #endif #endif // NLOHMANN_JSON_SERIALIZE_ENUM uses a static std::pair @@ -664,6 +666,7 @@ TEST_CASE("regression tests 2") } #ifdef JSON_HAS_CPP_20 +#if __has_include() SECTION("issue #2546 - parsing containers of std::byte") { const char DATA[] = R"("Hello, world!")"; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) @@ -671,6 +674,7 @@ TEST_CASE("regression tests 2") const json j = json::parse(s); CHECK(j.dump() == "\"Hello, world!\""); } +#endif #endif SECTION("issue #2574 - Deserialization to std::array, std::pair, and std::tuple with non-default constructable types fails")