diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index fb047661b..4e4918c3c 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -59,13 +59,12 @@ jobs: ci_cmake_options: runs-on: ubuntu-latest + container: ghcr.io/nlohmann/json-ci:v2.4.0 strategy: matrix: target: [ci_test_diagnostics, ci_test_noexceptions, ci_test_noimplicitconversions, ci_test_legacycomparison, ci_test_noglobaludls] steps: - uses: actions/checkout@v3 - - name: Get latest CMake and ninja - uses: lukka/get-cmake@latest - name: Run CMake run: cmake -S . -B build -DJSON_CI=On - name: Build @@ -121,6 +120,19 @@ jobs: - name: Build run: cmake --build build --target ci_test_compiler_default + ci_test_compilers: + runs-on: ubuntu-latest + container: ghcr.io/nlohmann/json-ci:v2.4.0 + strategy: + matrix: + compiler: [g++-4.8] + steps: + - uses: actions/checkout@v3 + - name: Run CMake + run: cmake -S . -B build -DJSON_CI=On + - name: Build + run: cmake --build build --target ci_test_compiler_${{ matrix.compiler }} + ci_test_standards: runs-on: ubuntu-latest container: ghcr.io/nlohmann/json-ci:v2.4.0 diff --git a/cmake/ci.cmake b/cmake/ci.cmake index 26f8e88c8..13adbc823 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -905,6 +905,30 @@ add_custom_target(ci_cmake_flags # Use more installed compilers. ############################################################################### +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() + + add_custom_target(ci_test_compiler_${COMPILER} + COMMAND CXX=${COMPILER} ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON -DJSON_FastTests=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_compiler_${COMPILER} + ${ADDITIONAL_FLAGS} + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_compiler_${COMPILER} + COMMAND cd ${PROJECT_BINARY_DIR}/build_compiler_${COMPILER} && ${CMAKE_CTEST_COMMAND} --parallel ${N} --exclude-regex "test-unicode" --output-on-failure + COMMENT "Compile and test with ${COMPILER}" + ) + endif() + unset(COMPILER_TOOL CACHE) +endforeach() + add_custom_target(ci_test_compiler_default COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug -GNinja