Skip to content

Commit 9994883

Browse files
authored
Add VCPKG usage to GitHub Actions (#149)
1 parent 8999597 commit 9994883

File tree

7 files changed

+123
-15
lines changed

7 files changed

+123
-15
lines changed

.github/workflows/main.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
matrix:
3131
os: [windows-2019, windows-2022]
32-
build_type: [x64-Debug, x64-Release, x64-Debug-Clang, x64-Release-Clang]
32+
build_type: [x64-Debug, x64-Release]
3333
arch: [amd64]
3434
include:
3535
- os: windows-2019
@@ -38,18 +38,18 @@ jobs:
3838
- os: windows-2019
3939
build_type: x86-Release
4040
arch: amd64_x86
41-
- os: windows-2019
42-
build_type: x86-Debug-Clang
43-
arch: amd64_x86
44-
- os: windows-2019
45-
build_type: x86-Release-Clang
46-
arch: amd64_x86
4741
- os: windows-2022
4842
build_type: x86-Debug
4943
arch: amd64_x86
5044
- os: windows-2022
5145
build_type: x86-Release
5246
arch: amd64_x86
47+
- os: windows-2022
48+
build_type: x64-Debug-Clang
49+
arch: amd64
50+
- os: windows-2022
51+
build_type: x64-Release-Clang
52+
arch: amd64
5353
- os: windows-2022
5454
build_type: x86-Debug-Clang
5555
arch: amd64_x86

.github/workflows/test.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333

3434
matrix:
3535
os: [windows-2019, windows-2022]
36-
build_type: [x64-Debug, x64-Release, x64-Debug-Clang, x64-Release-Clang]
36+
build_type: [x64-Debug, x64-Release]
3737
arch: [amd64]
3838
include:
3939
- os: windows-2019
@@ -42,18 +42,18 @@ jobs:
4242
- os: windows-2019
4343
build_type: x86-Release
4444
arch: amd64_x86
45-
- os: windows-2019
46-
build_type: x86-Debug-Clang
47-
arch: amd64_x86
48-
- os: windows-2019
49-
build_type: x86-Release-Clang
50-
arch: amd64_x86
5145
- os: windows-2022
5246
build_type: x86-Debug
5347
arch: amd64_x86
5448
- os: windows-2022
5549
build_type: x86-Release
5650
arch: amd64_x86
51+
- os: windows-2022
52+
build_type: x64-Debug-Clang
53+
arch: amd64
54+
- os: windows-2022
55+
build_type: x64-Release-Clang
56+
arch: amd64
5757
- os: windows-2022
5858
build_type: x86-Debug-Clang
5959
arch: amd64_x86

.github/workflows/vcpkg.yml

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
#
4+
# https://go.microsoft.com/fwlink/?LinkID=324981
5+
6+
name: 'CMake (Windows using VCPKG)'
7+
8+
on:
9+
push:
10+
branches: [ "main" ]
11+
pull_request:
12+
branches: [ "main" ]
13+
paths-ignore:
14+
- '*.md'
15+
- LICENSE
16+
- build/*
17+
18+
jobs:
19+
build:
20+
runs-on: ${{ matrix.os }}
21+
22+
strategy:
23+
fail-fast: false
24+
25+
matrix:
26+
os: [windows-2019, windows-2022]
27+
build_type: [x64-Debug-VCPKG]
28+
arch: [amd64]
29+
include:
30+
- os: windows-2022
31+
build_type: x64-Debug-Clang-VCPKG
32+
arch: amd64
33+
- os: windows-2022
34+
build_type: x86-Debug-VCPKG
35+
arch: amd64_x86
36+
- os: windows-2022
37+
build_type: arm64-Debug-VCPKG
38+
arch: amd64_arm64
39+
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: 'Install Ninja'
44+
run: choco install ninja
45+
46+
- uses: ilammy/msvc-dev-cmd@v1
47+
with:
48+
arch: ${{ matrix.arch }}
49+
50+
- name: 'Set triplet'
51+
shell: pwsh
52+
run: |
53+
if ("${{ matrix.arch }}" -eq "amd64")
54+
{
55+
echo "VCPKG_DEFAULT_TRIPLET=x64-windows" >> $env:GITHUB_ENV
56+
}
57+
elseif ("${{ matrix.arch }}" -eq "amd64_x86")
58+
{
59+
echo "VCPKG_DEFAULT_TRIPLET=x86-windows" >> $env:GITHUB_ENV
60+
}
61+
elseif ("${{ matrix.arch }}" -eq "amd64_arm64")
62+
{
63+
if ("${{ matrix.build_type }}" -match "^arm64ec")
64+
{
65+
echo "VCPKG_DEFAULT_TRIPLET=arm64ec-windows" >> $env:GITHUB_ENV
66+
}
67+
else
68+
{
69+
echo "VCPKG_DEFAULT_TRIPLET=arm64-windows" >> $env:GITHUB_ENV
70+
}
71+
}
72+
else
73+
{
74+
echo "::error Unknown architecture/build-type triplet mapping"
75+
}
76+
77+
- uses: lukka/run-vcpkg@v11
78+
with:
79+
runVcpkgInstall: true
80+
vcpkgJsonGlob: '**/build/vcpkg.json'
81+
vcpkgGitCommitId: '7516a02de04e8f8ff4e4beb8f5bac0565f9bf9da'
82+
83+
- name: 'Configure CMake'
84+
working-directory: ${{ github.workspace }}
85+
run: >
86+
cmake --preset=${{ matrix.build_type }} -DBUILD_TESTING=OFF
87+
-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_MANIFEST_DIR="${{ github.workspace }}/build"
88+
-DVCPKG_TARGET_TRIPLET="${env:VCPKG_DEFAULT_TRIPLET}"
89+
90+
- name: 'Build'
91+
working-directory: ${{ github.workspace }}
92+
run: cmake --build out\build\${{ matrix.build_type }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ x64
2828
/wiki
2929
/out
3030
/CMakeUserPresets.json
31+
/build/vcpkg_installed

CMakePresets.json

+7
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@
226226
{ "name": "arm64-Debug-Clang" , "description": "Clang/LLVM for AArch64 (Debug) with DX12", "inherits": [ "base", "ARM64", "Debug", "Clang" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } },
227227
{ "name": "arm64-Release-Clang", "description": "Clang/LLVM for AArch64 (Release) with DX12", "inherits": [ "base", "ARM64", "Release", "Clang" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } },
228228

229+
{ "name": "x64-Debug-Clang-VCPKG" , "description": "Clang/LLVM for x64 (Debug) using VCPKG", "inherits": [ "base", "x64", "Debug", "Clang", "VCPKG" ] },
230+
{ "name": "x64-Release-Clang-VCPKG" , "description": "Clang/LLVM for x64 (Release) using VCPKG", "inherits": [ "base", "x64", "Release", "Clang", "VCPKG" ] },
231+
{ "name": "x86-Debug-Clang-VCPKG" , "description": "Clang/LLVM for x86 (Debug) using VCPKG", "inherits": [ "base", "x86", "Debug", "Clang", "VCPKG" ], "environment": { "CXXFLAGS": "-m32" } },
232+
{ "name": "x86-Release-Clang-VCPKG" , "description": "Clang/LLVM for x86 (Release) using VCPKG", "inherits": [ "base", "x86", "Release", "Clang", "VCPKG" ], "environment": { "CXXFLAGS": "-m32" } },
233+
{ "name": "arm64-Debug-Clang-VCPKG" , "description": "Clang/LLVM for AArch64 (Debug) using VCPKG", "inherits": [ "base", "ARM64", "Debug", "Clang", "VCPKG" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } },
234+
{ "name": "arm64-Release-Clang-VCPKG", "description": "Clang/LLVM for AArch64 (Release) using VCPKG", "inherits": [ "base", "ARM64", "Release", "Clang", "VCPKG" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } },
235+
229236
{ "name": "x64-Debug-UWP-Clang" , "description": "Clang/LLVM for x64 (Debug) for UWP", "inherits": [ "base", "x64", "Debug", "Clang", "UWP" ] },
230237
{ "name": "x64-Release-UWP-Clang" , "description": "Clang/LLVM for x64 (Release) for UWP", "inherits": [ "base", "x64", "Release", "Clang", "UWP" ] },
231238
{ "name": "x86-Debug-UWP-Clang" , "description": "Clang/LLVM for x86 (Debug) for UWP", "inherits": [ "base", "x86", "Debug", "Clang", "UWP" ], "environment": { "CXXFLAGS": "-m32" } },

build/CompilerAndLinker.cmake

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
136136
list(APPEND COMPILER_SWITCHES /Zc:lambda)
137137
endif()
138138

139-
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.29)
139+
if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.29)
140+
AND (NOT VCPKG_TOOLCHAIN))
140141
list(APPEND COMPILER_SWITCHES /external:W4)
141142
endif()
142143

build/vcpkg.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
3+
"dependencies": [
4+
"directxmath",
5+
"directx-headers"
6+
]
7+
}

0 commit comments

Comments
 (0)