From 3ac1c990464181a845045a3b978c35ae85173d5d Mon Sep 17 00:00:00 2001 From: Sergii Kryvonos Date: Tue, 1 Oct 2024 18:22:46 +0200 Subject: [PATCH] Fix fetching sources of specific version with 'prerequisites' target --- .github/workflows/conan.yml | 56 ++++++++++++++++++++++++++++++++++ .github/workflows/docker.yml | 2 +- .github/workflows/macos.yml | 2 +- .github/workflows/ubuntu.yml | 2 +- .github/workflows/windows.yml | 28 ++++------------- cmake/find_local_package.cmake | 16 +++++++--- 6 files changed, 76 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/conan.yml diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml new file mode 100644 index 000000000..a9c104b25 --- /dev/null +++ b/.github/workflows/conan.yml @@ -0,0 +1,56 @@ +name: C/C++ CI Conan + +on: [push] + +jobs: + build-on-windows: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + - uses: ilammy/msvc-dev-cmd@v1 + - name: Cache Boost dependencies + uses: actions/cache@v4 + with: + path: | + ${{ github.workspace }}/build/conan + ${{ github.workspace }}/build/CMakeFiles + C:/Boost + key: ${{ runner.os }}-boost-${{ hashFiles('**/conanfile.txt') }} + restore-keys: | + ${{ runner.os }}-boost- + - name: Create Build Dir + run: cmake -E make_directory ${{github.workspace}}/build + - name: Use Conan + run: | + pip install conan && conan profile detect + + echo "[requires]" > ${{github.workspace}}/conanfile.txt + echo boost/1.84.0 >> ${{github.workspace}}/conanfile.txt + echo leveldb/1.23 >> ${{github.workspace}}/conanfile.txt + + echo "[generators]" >> ${{github.workspace}}/conanfile.txt + echo CMakeDeps >> ${{github.workspace}}/conanfile.txt + echo CMakeToolchain >> ${{github.workspace}}/conanfile.txt + - name: Configure + working-directory: ${{github.workspace}}/build + env: + CC: cl + run: cmake ${{github.workspace}} -DOPENMIND_USE_CONAN=ON -DOPENMIND_USE_VCPKG=NO -DOPENMIND_BUILD_SAMPLES=NO -DOPENMIND_BUILD_TESTS=ON -G "Ninja Multi-Config" -D CMAKE_C_COMPILER="cl.exe" -D CMAKE_CXX_COMPILER="cl.exe" -DOPENMIND_MATH_USE_LEVELDB_CACHE=ON -DOPENMIND_STORAGE_LEVELDB=ON + - name: Install prerequisites with conan + working-directory: ${{github.workspace}}/build + run: cmake --build ${{github.workspace}}/build --target Install__Conan --config Release + - name: Reconfigure to detect newly installed prerequisites + working-directory: ${{github.workspace}}/build + run: cmake --preset conan-default + - name: Build + working-directory: ${{github.workspace}}/build + run: cmake --preset conan-default --build + - name: Get number of CPU cores + uses: SimenB/github-actions-cpu-cores@v2 + id: cpu-cores + - name: check + working-directory: ${{github.workspace}}/build + run: ctest --preset conan-default --timeout 240 -j ${{steps.cpu-cores.outputs.count}} -E "image_codec_test|ts|Polyfit_test" --output-on-failure + # --rerun-failed --output-on-failure diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index be6d48ed0..952b2dda7 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,4 +1,4 @@ -name: C/C++ CI +name: C/C++ CI Docker on: [push] diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index c509f4be1..6751a43f2 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -1,4 +1,4 @@ -name: C/C++ CI +name: C/C++ CI macOS on: [push] diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 9ab513dd1..487a7a9af 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -1,4 +1,4 @@ -name: C/C++ CI +name: C/C++ CI Ubuntu on: [push] diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index fd0e8303f..088f6873a 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -1,4 +1,4 @@ -name: C/C++ CI +name: C/C++ CI MSVC on: [push] @@ -8,42 +8,26 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ilammy/msvc-dev-cmd@v1 - name: Cache Boost dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | - ${{ github.workspace }}/build/conan ${{ github.workspace }}/build/CMakeFiles C:/Boost - key: ${{ runner.os }}-boost-${{ hashFiles('**/conanfile.txt') }} + key: ${{ runner.os }}-boost-${{ hashFiles('**/vcpkg.json') }} restore-keys: | ${{ runner.os }}-boost- - name: Create Build Dir run: cmake -E make_directory ${{github.workspace}}/build - - name: Use Conan - run: | - pip install conan && conan profile detect - echo "[requires]" > ${{github.workspace}}/conanfile.txt - echo boost/1.84.0 >> ${{github.workspace}}/conanfile.txt - echo leveldb/1.23 >> ${{github.workspace}}/conanfile.txt - - echo "[generators]" >> ${{github.workspace}}/conanfile.txt - echo CMakeDeps >> ${{github.workspace}}/conanfile.txt - echo CMakeToolchain >> ${{github.workspace}}/conanfile.txt - name: Configure working-directory: ${{github.workspace}}/build env: CC: cl - run: cmake ${{github.workspace}} -DOPENMIND_USE_CONAN=OFF -DOPENMIND_USE_VCPKG=NO -DOPENMIND_BUILD_SAMPLES=OFF -DOPENMIND_BUILD_TESTS=ON -G "Ninja Multi-Config" -D CMAKE_C_COMPILER="cl.exe" -D CMAKE_CXX_COMPILER="cl.exe" -Dleveldb_TAG:STRING="1.23" -DOPENMIND_MATH_USE_LEVELDB_CACHE=OFF -DOPENMIND_STORAGE_LEVELDB=OFF - - name: Install prerequisites with conan - working-directory: ${{github.workspace}}/build - run: cmake --build ${{github.workspace}}/build --target Install__Conan --config Release - - name: Reconfigure to detect newly installed prerequisites - working-directory: ${{github.workspace}}/build - run: cmake . -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/conan_toolchain.cmake + run: cmake ${{github.workspace}} -DOPENMIND_USE_CONAN=OFF -DOPENMIND_USE_VCPKG=NO -DOPENMIND_BUILD_SAMPLES=OFF -DOPENMIND_BUILD_TESTS=ON -G "Ninja Multi-Config" -D CMAKE_C_COMPILER="cl.exe" -D CMAKE_CXX_COMPILER="cl.exe" -Dleveldb_TAG:STRING="1.23" -DOPENMIND_MATH_USE_LEVELDB_CACHE=ON -DOPENMIND_STORAGE_LEVELDB=ON + - name: Install prerequisites working-directory: ${{github.workspace}}/build run: cmake --build ${{github.workspace}}/build --target prerequisites --config Release diff --git a/cmake/find_local_package.cmake b/cmake/find_local_package.cmake index 4af31afb0..0fb147b07 100644 --- a/cmake/find_local_package.cmake +++ b/cmake/find_local_package.cmake @@ -40,13 +40,19 @@ macro(find_pkg) foreach(dep ${ARGN}) if(NOT ${dep}_FOUND) if(${dep}_VERSION) - message("find_package(${dep} ${${dep}_VERSION} REQUIRED)") - find_package(${dep} ${${dep}_VERSION} REQUIRED) + find_package(${dep} ${${dep}_VERSION}) + if(${dep}_FOUND) + message("find_package(${dep} ${${dep}_VERSION} REQUIRED)") + find_package(${dep} ${${dep}_VERSION} REQUIRED) + endif() elseif(${dep}_TAG AND NOT ${dep}_TAG STREQUAL HEAD) - message("find_package(${dep} ${${dep}_TAG} REQUIRED)") - find_package(${dep} ${${dep}_TAG} REQUIRED) + find_package(${dep} ${${dep}_TAG}) + if(${dep}_FOUND) + message("find_package(${dep} ${${dep}_TAG} REQUIRED)") + find_package(${dep} ${${dep}_TAG} REQUIRED) + endif() else() - message("find_package(${dep} REQUIRED)") + message("find_package(${dep})") find_package(${dep}) endif() endif()