generated from vis4rd/opengl_project_template
-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (75 loc) · 2.99 KB
/
cmake.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: CMake
on:
pull_request:
branches: [ "dev" ]
paths: [ "src/**" ]
types: [ opened, synchronize, reopened, ready_for_review ]
jobs:
build:
if: ${{ github.event.pull_request.draft == false }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04]
build_type: [Release]
c_compiler: [gcc, clang]
include:
- os: ubuntu-24.04
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-24.04
c_compiler: clang
cpp_compiler: clang++
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: false
- name: Prepare environment
id: env
uses: ./.github/actions/prepare_env
- name: Load cache build directory
uses: actions/cache/restore@v3
id: restore-cache
with:
path: ${{ steps.env.outputs.build-output-dir }}
key: ${{ runner.os }}-build-${{ matrix.c_compiler }}-${{ matrix.cpp_compiler }}-${{ matrix.build_type }}-${{ hashFiles('src/engine/module/**/*', 'src/game/**/*') }}
restore-keys: ${{ runner.os }}-build-${{ matrix.c_compiler }}-${{ matrix.cpp_compiler }}-${{ matrix.build_type }}-
- name: Configure ccache
run: |
export CCACHE_DIR=${{ steps.env.outputs.ccache-output-dir }}
echo "CCACHE_DIR=$CCACHE_DIR" >> $GITHUB_ENV
ccache --max-size=10M --zero-stats
- name: Configure CMake
working-directory: ${{ steps.env.outputs.build-output-dir }}
run: >
cmake
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
..
- name: Build
# Build your program with the given configuration. Note that --config is needed because the
# default Windows generator is a multi-config generator (Visual Studio generator).
working-directory: ${{ steps.env.outputs.build-output-dir }}
run: cmake --build . --config ${{ matrix.build_type }} --parallel
- name: Show ccache statistics
run: |
ccache --show-stats --verbose
du -sh $CCACHE_DIR
ccache --zero-stats # Statistics are not necessary in cache artifact
- name: Cache build directory
uses: actions/cache/save@v3
with:
path: ${{ steps.env.outputs.build-output-dir }}
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
# - name: Test
# working-directory: ${{ steps.env.outputs.build-output-dir }}
# # Execute tests defined by the CMake configuration. Note that --build-config is needed
# # because the default Windows generator is a multi-config generator (Visual Studio generator).
# # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: ctest --build-config ${{ matrix.build_type }}