add cmake checks caching

This commit is contained in:
ohyzha
2024-10-21 17:56:20 +03:00
parent 74a9294aeb
commit 99a159d554
4 changed files with 44 additions and 2 deletions

View File

@@ -34,8 +34,23 @@ jobs:
run: >
sudo apt update && sudo apt install -y extra-cmake-modules libwayland-dev libxkbcommon-dev xorg-dev libarchive-dev libassimp-dev ninja-build glslang-tools glslang-dev unzip zip libcurl4-openssl-dev libfreetype-dev libjpeg-turbo8-dev nasm
&& sudo wget https://sourceforge.net/projects/bin2c/files/1.1/bin2c-1.1.zip && sudo unzip bin2c-1.1.zip && cd bin2c && sudo gcc -o bin2c bin2c.c && sudo mv bin2c /usr/bin
- name: Get cmake checks from cache
uses: actions/cache/restore@v3
id: cache
with:
path: |
${{github.workspace}}/build/cmake_checks_cache.txt
${{github.workspace}}/build/CMakeFiles/**/CMake*.cmake
key: ${{runner.os}}-cmakeChecks
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DDEPENDENCY_MIRROR_FILE="${{github.workspace}}/.gitea/workflows/DependencyMirrors.txt"
run: |
if [ "${{ steps.cache.outputs.cache-hit }}" != "true" ]; then
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DDEPENDENCY_MIRROR_FILE="${{github.workspace}}/.gitea/workflows/DependencyMirrors.txt"
else
cmake -B ${{github.workspace}}/build -C ${{github.workspace}}/build/cmake_checks_cache.txt -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DDEPENDENCY_MIRROR_FILE="${{github.workspace}}/.gitea/workflows/DependencyMirrors.txt"
fi
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Test
@@ -66,6 +81,16 @@ jobs:
if-no-files-found: error
retention-days: 30
overwrite: true
- name: Cache cmake checks
if: steps.cache.outputs.cache-hit != 'true'
id: cache-cmake-checks
uses: actions/cache/save@v3
with:
path: |
${{github.workspace}}/build/cmake_checks_cache.txt
${{github.workspace}}/build/CMakeFiles/**/CMake*.cmake
key: ${{runner.os}}-cmakeChecks

View File

@@ -32,6 +32,7 @@ add_subdirectory(boost)
add_subdirectory(units)
add_subdirectory(libjpeg-turbo)
add_subdirectory(msdf)
add_subdirectory(cmake-checks-cache)
if (NOT IOS AND ENABLE_CURL)
add_subdirectory(curl)
endif()

View File

@@ -0,0 +1,14 @@
include (FetchContent)
if(NOT DEFINED CMAKE_CHECKS_REPO)
set(CMAKE_CHECKS_REPO https://github.com/cristianadam/cmake-checks-cache.git)
endif ()
FetchContent_Declare(
cmake-checks-cache
GIT_REPOSITORY ${CMAKE_CHECKS_REPO}
GIT_TAG master
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(cmake-checks-cache)

View File

@@ -15,7 +15,9 @@ if(LINUX)
find_package(ECM REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/functions")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_BINARY_DIR}/_deps/cmake-checks-cache-src/CMakeChecksCache"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/functions")
include(VarsFromFile)
include(SetCompilerSettings)