Skip to content

Commit

Permalink
Github workflow for building on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kkosciusz committed Jun 15, 2024
1 parent a851308 commit a29e6d4
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build-windows-vcpkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright (c) 2019-2020-2021-2022 Luca Cappa
# Released under the term specified in file LICENSE.txt
# SPDX short identifier: MIT
#
# Source: https://raw.githubusercontent.com/lukka/CppBuildTasks-Validation/v10/.github/workflows/hosted-ninja-vcpkg_submod-autocache.yml
name: Build on Windows with VCPKG
on: [push, workflow_dispatch]

jobs:
job:
name: ${{ matrix.os }}-${{ github.workflow }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [windows-latest]

steps:
- uses: actions/checkout@v3
with:
submodules: true
# This is useful to avoid https://github.com/microsoft/vcpkg/issues/25349
# which is caused by missing Git history on the vcpkg submodule which ports
# try to access.
fetch-depth: 0

- uses: lukka/get-cmake@latest
- name: List $RUNNER_WORKSPACE before vcpkg is setup
run: find $RUNNER_WORKSPACE
shell: bash

- name: Restore vcpkg executable and data files from GH Action cache, or setup vcpkg from scratch if there is a cache-miss
uses: lukka/run-vcpkg@v11
id: runvcpkg
with:
# This one is not needed, as it is the default value anyway.
# vcpkgDirectory: '${{ github.workspace }}/vcpkg'
vcpkgJsonGlob: 'vcpkg.json'
# Leverage the cache containing vcpkg executable and data files (e.g. port files).
doNotCache: false

- name: List $RUNNER_WORKSPACE before build
run: find $RUNNER_WORKSPACE
shell: bash
- name: Prints output of run-vcpkg's action.
run: echo "root='${{ steps.runvcpkg.outputs.RUNVCPKG_VCPKG_ROOT_OUT }}', triplet='${{ steps.runvcpkg.outputs.RUNVCPKG_VCPKG_DEFAULT_TRIPLET_OUT }}' "
- name: Run CMake+vcpkg+Ninja
uses: lukka/run-cmake@v10
id: runcmake
with:
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
configurePreset: 'windows-release'
buildPreset: 'windows-release'
#packagePreset: 'windows-release'
- name: List $RUNNER_WORKSPACE after build
run: find $RUNNER_WORKSPACE
shell: bash
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vcpkg"]
path = vcpkg
url = https://github.com/microsoft/vcpkg.git
63 changes: 63 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 21,
"patch": 0
},
"configurePresets": [
{
"name": "debug",
"displayName": "Debug build settings",
"binaryDir": "${sourceDir}/build/debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "release",
"displayName": "Release build settings",
"binaryDir": "${sourceDir}/build/release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "windows",
"displayName": "Windows build vcpkg & ninja settings",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "./vcpkg/scripts/buildsystems/vcpkg.cmake",
"VCPKG_TARGET_TRIPLET": "x64-windows"
}
},
{
"name": "windows-release",
"displayName": "Windows release build",
"inherits": [
"release",
"windows"
]
},
{
"name": "windows-debug",
"displayName": "Windows debug build",
"inherits": [
"debug",
"windows"
]
}
],
"buildPresets": [
{
"name": "windows-release",
"displayName": "Windows release build",
"configurePreset": "windows-release"
},
{
"name": "windows-debug",
"displayName": "Windows debug build",
"configurePreset": "windows-debug"
}
]
}
1 change: 1 addition & 0 deletions vcpkg
Submodule vcpkg added at b0d9d5

0 comments on commit a29e6d4

Please sign in to comment.