-
Notifications
You must be signed in to change notification settings - Fork 45
60 lines (48 loc) · 2.03 KB
/
windows.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
name: Windows
on: [push, pull_request]
jobs:
vs2022:
strategy:
fail-fast: false
matrix:
arch: ['x86', 'x64']
libs: ['shared', 'static']
config: ['Debug', 'Release']
runs-on: windows-latest
steps:
- uses: actions/[email protected]
with:
submodules: true
- name: Set target triplet
id: set-variables
shell: pwsh
run: echo "vcpkg_triplet=${{ matrix.arch }}-windows$(if ('${{ matrix.libs }}' -eq 'static') { '-static' })" >> $env:GITHUB_OUTPUT
- name: Cache vcpkg
uses: actions/[email protected]
id: cache-vcpkg
with:
path: build/vcpkg_cache/
key: vcpkg-binaries-${{ steps.set-variables.outputs.vcpkg_triplet }}
- name: Create Build Environment
if: ${{ !steps.cache-vcpkg.outputs.cache-hit }}
run: |
cmake -E make_directory build
cmake -E make_directory build/vcpkg_cache
- name: Configure
shell: pwsh
working-directory: build/
run: |
$vcpkgToolchain = Join-Path $env:VCPKG_INSTALLATION_ROOT '.\scripts\buildsystems\vcpkg.cmake' -Resolve
$vcpkgTriplet = '${{ steps.set-variables.outputs.vcpkg_triplet }}'
$cmakeSharedLibs = $(if ('${{ matrix.libs }}' -eq 'shared') { 'ON' } else { 'OFF' })
$msbuildArch = $(if ('${{ matrix.arch }}' -eq 'x64') { 'X64' } else { 'Win32' })
$cachedBinaries = Join-Path $(Get-Location) './vcpkg_cache/' -Resolve
$cacheAccess = $(if ('${{ steps.cache-vcpkg.outputs.cache-hit }}' -eq 'true') { 'read' } else { 'write' })
$env:VCPKG_BINARY_SOURCES = "clear;files,$cachedBinaries,$cacheAccess"
cmake "-DCMAKE_TOOLCHAIN_FILE=$vcpkgToolchain" "-DVCPKG_TARGET_TRIPLET=$vcpkgTriplet" "-DBUILD_SHARED_LIBS=$cmakeSharedLibs" -G "Visual Studio 17 2022" -A "$msbuildArch" ${{ github.workspace }}
- name: Build
working-directory: build/
run: cmake --build . --config ${{ matrix.config }} -j -v
- name: Test
working-directory: build/
run: ctest -C ${{ matrix.config }} --output-on-failure