Skip to content

Commit 9850897

Browse files
authored
Add VCPKG usage to GitHub Actions (#499)
1 parent 1c47191 commit 9850897

File tree

8 files changed

+128
-16
lines changed

8 files changed

+128
-16
lines changed

.github/workflows/main.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030

3131
matrix:
3232
os: [windows-2019, windows-2022]
33-
build_type: [x64-Debug, x64-Release, x64-Debug-Clang, x64-Release-Clang]
33+
build_type: [x64-Debug, x64-Release]
3434
arch: [amd64]
3535
include:
3636
- os: windows-2019
@@ -39,18 +39,18 @@ jobs:
3939
- os: windows-2019
4040
build_type: x86-Release
4141
arch: amd64_x86
42-
- os: windows-2019
43-
build_type: x86-Debug-Clang
44-
arch: amd64_x86
45-
- os: windows-2019
46-
build_type: x86-Release-Clang
47-
arch: amd64_x86
4842
- os: windows-2022
4943
build_type: x86-Debug
5044
arch: amd64_x86
5145
- os: windows-2022
5246
build_type: x86-Release
5347
arch: amd64_x86
48+
- os: windows-2022
49+
build_type: x64-Debug-Clang
50+
arch: amd64
51+
- os: windows-2022
52+
build_type: x64-Release-Clang
53+
arch: amd64
5454
- os: windows-2022
5555
build_type: x86-Debug-Clang
5656
arch: amd64_x86

.github/workflows/test.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434

3535
matrix:
3636
os: [windows-2019, windows-2022]
37-
build_type: [x64-Debug, x64-Release, x64-Debug-Clang, x64-Release-Clang]
37+
build_type: [x64-Debug, x64-Release]
3838
arch: [amd64]
3939
include:
4040
- os: windows-2019
@@ -43,18 +43,18 @@ jobs:
4343
- os: windows-2019
4444
build_type: x86-Release
4545
arch: amd64_x86
46-
- os: windows-2019
47-
build_type: x86-Debug-Clang
48-
arch: amd64_x86
49-
- os: windows-2019
50-
build_type: x86-Release-Clang
51-
arch: amd64_x86
5246
- os: windows-2022
5347
build_type: x86-Debug
5448
arch: amd64_x86
5549
- os: windows-2022
5650
build_type: x86-Release
5751
arch: amd64_x86
52+
- os: windows-2022
53+
build_type: x64-Debug-Clang
54+
arch: amd64
55+
- os: windows-2022
56+
build_type: x64-Release-Clang
57+
arch: amd64
5858
- os: windows-2022
5959
build_type: x86-Debug-Clang
6060
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+
# http://go.microsoft.com/fwlink/?LinkId=248926
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 -DENABLE_OPENEXR_SUPPORT=ON -DENABLE_LIBJPEG_SUPPORT=ON -DENABLE_LIBPNG_SUPPORT=ON
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
@@ -38,3 +38,4 @@ x64
3838
/wiki
3939
/out
4040
/CMakeUserPresets.json
41+
/build/vcpkg_installed

Auxiliary/DirectXTexEXR.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ HRESULT DirectX::SaveToEXRFile(const Image& image, const wchar_t* szFile)
544544
{
545545
const uint64_t bytes = image.width * image.height;
546546

547-
if (bytes > UINT32_MAX)
547+
if (bytes > static_cast<uint64_t>(UINT32_MAX))
548548
{
549549
return /* HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW) */ static_cast<HRESULT>(0x80070216L);
550550
}

CMakePresets.json

+7
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,13 @@
304304
{ "name": "x86-Debug-Win7-Clang" , "description": "Clang/LLVM for x86 (Debug) for Windows 7", "inherits": [ "base", "x86", "Debug", "Clang", "Win7" ], "environment": { "CXXFLAGS": "-m32" } },
305305
{ "name": "x86-Release-Win7-Clang", "description": "Clang/LLVM for x86 (Release) for Windows 7", "inherits": [ "base", "x86", "Release", "Clang", "Win7" ], "environment": { "CXXFLAGS": "-m32" } },
306306

307+
{ "name": "x64-Debug-Clang-VCPKG" , "description": "Clang/LLVM for x64 (Debug) using VCPKG/OpenEXR", "inherits": [ "base", "x64", "Debug", "Clang", "VCPKG" ] },
308+
{ "name": "x64-Release-Clang-VCPKG" , "description": "Clang/LLVM for x64 (Release) using VCPKG/OpenEXR", "inherits": [ "base", "x64", "Release", "Clang", "VCPKG" ] },
309+
{ "name": "x86-Debug-Clang-VCPKG" , "description": "Clang/LLVM for x86 (Debug) using VCPKG/OpenEXR", "inherits": [ "base", "x86", "Debug", "Clang", "VCPKG" ], "environment": { "CXXFLAGS": "-m32" } },
310+
{ "name": "x86-Release-Clang-VCPKG" , "description": "Clang/LLVM for x86 (Release) using VCPKG/OpenEXR", "inherits": [ "base", "x86", "Release", "Clang", "VCPKG" ], "environment": { "CXXFLAGS": "-m32" } },
311+
{ "name": "arm64-Debug-Clang-VCPKG" , "description": "Clang/LLVM for AArch64 (Debug) using VCPKG/OpenEXR", "inherits": [ "base", "ARM64", "Debug", "Clang", "VCPKG" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } },
312+
{ "name": "arm64-Release-Clang-VCPKG", "description": "Clang/LLVM for AArch64 (Release) using VCPKG/OpenEXR", "inherits": [ "base", "ARM64", "Release", "Clang", "VCPKG" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } },
313+
307314
{ "name": "x64-Debug-Clang-JPEG-PNG" , "description": "Clang/LLVM for x64 (Debug) with DX12", "inherits": [ "base", "x64", "Debug", "Clang", "VCPKG", "JPEG_PNG" ] },
308315
{ "name": "x64-Release-Clang-JPEG-PNG" , "description": "Clang/LLVM for x64 (Release) with DX12", "inherits": [ "base", "x64", "Release", "Clang", "VCPKG", "JPEG_PNG" ] },
309316

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

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

0 commit comments

Comments
 (0)