-
Notifications
You must be signed in to change notification settings - Fork 1
155 lines (134 loc) · 6.07 KB
/
build_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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Roughly based on
# https://github.com/flameshot-org/flameshot/blob/master/.github/workflows/build_cmake.yml
# https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml
# https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
# https://github.com/lukka/CppCMakeVcpkgTemplate/blob/v11/.github/workflows/hosted-pure-workflow.yml
# https://github.com/lukka/CppBuildTasks-Validation/blob/v10/.github/workflows/hosted-ninja-vcpkg.yml
name: CMake build of Quadelect
on: [push, pull_request]
env:
# Indicates the location of the vcpkg as a Git submodule of the project repository.
# Not using "VCPKG_ROOT" because a variable with the same name is defined in the VS's
# Developer Command Prompt environment in VS 2022 17.6, which would override this one
# if it had the same name.
_VCPKG_: ${{ github.workspace }}/vcpkg
# Tells vcpkg where binary packages are stored.
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vcpkg/bincache
# Let's use GitHub Action cache as storage for the vcpkg Binary Caching feature.
VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite'
jobs:
# Maybe separate Windows and Linux instead of having a bunch of ifs?
# Consider the possibility, at least...
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, windows-latest]
build_type: [Release]
# c++ is MinGW.
cpp_compiler: [g++, clang++, cl]
include:
- os: ubuntu-22.04
cpp_compiler: g++
- os: ubuntu-22.04
cpp_compiler: clang++
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
vckpgCommitId: '7f9f0e44db287e8e67c0e888141bfa200ab45121'
exclude:
- os: ubuntu-22.04
cpp_compiler: cl
- os: windows-latest
cpp_compiler: clang++
- os: windows-latest
# c_compiler keeps us from tripping if (MSVC) in
# CMakeLists.
# Currently disabled because it can't find libconfig++.
cpp_compiler: g++
#c_compiler: gcc
#vckpgCommitId: '7f9f0e44db287e8e67c0e888141bfa200ab45121'
name: ${{ matrix.os }}, ${{ matrix.cpp_compiler }}
steps:
# Windows caching steps from hosted-pure-workflow.yml
# Set env vars needed for vcpkg to leverage the GitHub Action cache as a storage
# for Binary Caching.
- name: Set cache URLs
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Checkout source code
if: github.event_name == 'push'
uses: actions/checkout@v4
with:
submodules: true
- name: Checkout source code
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
submodules: true
- if: matrix.os == 'windows-latest'
uses: ilammy/msvc-dev-cmd@v1.4.1
- name: "Create directory '${{ env.VCPKG_DEFAULT_BINARY_CACHE }}'"
run: mkdir -p $VCPKG_DEFAULT_BINARY_CACHE
shell: bash
# Setup the build machine with the most recent versions of CMake and Ninja.
# Both are cached if not already: on subsequent runs both will be quickly
# restored from GitHub cache service.
- uses: lukka/get-cmake@latest
# Restore vcpkg from the GitHub Action cache service. Note that packages are restored by vcpkg's binary caching
# when it is being run afterwards by CMake.
- name: Setup vcpkg (Windows)
if: matrix.os == 'windows-latest'
uses: lukka/run-vcpkg@v11
id: runvcpkg
with:
# This specifies the location of vcpkg, where it is going to be restored from cache, or create from scratch.
vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
# The Git commit id of vcpkg to be checked out. This is only needed because we are not using a submodule.
vcpkgGitCommitId: '${{ matrix.vcpkgCommitId}}'
# The vcpkg.json file, which will be part of cache key computation.
vcpkgJsonGlob: '**/vcpkg.json'
- name: Prints output of run-vcpkg's action (Windows)
if: matrix.os == 'windows-latest'
run: echo "root='${{ steps.runvcpkg.outputs.RUNVCPKG_VCPKG_ROOT_OUT }}', triplet='${{ steps.runvcpkg.outputs.RUNVCPKG_VCPKG_DEFAULT_TRIPLET_OUT }}'"
- name: Install dependencies (Linux)
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get -y -qq update
sudo apt-get -y --no-install-recommends install \
cmake \
extra-cmake-modules \
build-essential \
libglpk-dev \
libconfig++-dev \
libeigen3-dev \
libboost-container-dev
- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
# Not sure why this is needed??
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Configure CMake (Linux)
if: matrix.os == 'ubuntu-22.04'
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}
- name: Configure CMake (Windows)
if: matrix.os == 'windows-latest'
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }} --preset default
- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }}