From 0f507869c475defad90e97c6b75070efc7e2dcd3 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Wed, 10 May 2023 10:24:48 +0200 Subject: [PATCH] Use simplified FetchContent CI Signed-off-by: Cristian Le --- .github/workflows/test.yaml | 13 ------------- CMakeLists.txt | 8 +++++++- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 91bcb36..da22d3f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -30,19 +30,6 @@ jobs: runs-on: ubuntu-latest container: ghcr.io/nlohmann/json-ci:v2.4.0 steps: - - name: Clone nlohmann json version ${{ matrix.json_version }} - uses: actions/checkout@v3 - with: - repository: nlohmann/json - path: nlohmann-json - ref: ${{ matrix.json_version }} - # TODO: Move to FetchContent managed - - name: Build and install nlohmann json - run: | - cd nlohmann-json - cmake -S . -B build - cmake --build build --target install -j$(nproc) - cd .. - name: Clone json-schema-validator uses: actions/checkout@v3 - name: Run CMake ${{ matrix.toolchain }}-ci workflow with nlohmann/json version ${{ matrix.json_version }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 743ea25..ad441de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,13 @@ option(JSON_VALIDATOR_INSTALL "JsonValidator: Install targets" ${PROJECT_IS_TOP_ option(JSON_VALIDATOR_BUILD_TESTS "JsonValidator: Build tests" ${PROJECT_IS_TOP_LEVEL}) option(JSON_VALIDATOR_BUILD_EXAMPLES "JsonValidator: Build examples" ${PROJECT_IS_TOP_LEVEL}) option(JSON_VALIDATOR_SHARED_LIBS "JsonValidator: Build as shared library" ${PROJECT_IS_TOP_LEVEL}) -set(JSON_FETCH_VERSION v3.11.2 CACHE STRING "Fetch nlohmann::json version") +# Get a default JSON_FETCH_VERSION from environment variables to workaround the CI +if (DEFINED ENV{NLOHMANN_JSON_VERSION}) + set(JSON_FETCH_VERSION_DEFAULT $ENV{NLOHMANN_JSON_VERSION}) +else () + set(JSON_FETCH_VERSION_DEFAULT v3.11.2) +endif () +set(JSON_FETCH_VERSION ${JSON_FETCH_VERSION_DEFAULT} CACHE STRING "Fetch nlohmann::json version") #[==============================================================================================[ # Project configuration #