From caceccf1d516701cd0c6e536d951c43519e2e561 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 | 16 +--------------- CMakeLists.txt | 8 +++++++- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0093b92..15e1940 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -59,21 +59,7 @@ jobs: run: | update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-${{ matrix.compiler_version }}) 999 if: matrix.compiler_version && matrix.toolchain == 'llvm' - - 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 + - uses: actions/checkout@v3 # container version is < 3.25 which does not have workflows - name: Get latest cmake version uses: lukka/get-cmake@latest 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 #