Add VCPKG usage to GitHub Actions (#167)

This commit is contained in:
Chuck Walbourn 2024-08-23 10:05:23 -07:00 committed by GitHub
parent 2c7f6d8155
commit 49fbfc22dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 116 additions and 17 deletions

View File

@ -28,7 +28,7 @@ jobs:
matrix: matrix:
os: [windows-2019, windows-2022] os: [windows-2019, windows-2022]
build_type: [x64-Debug, x64-Release, x64-Debug-Clang, x64-Release-Clang] build_type: [x64-Debug, x64-Release]
arch: [amd64] arch: [amd64]
include: include:
- os: windows-2019 - os: windows-2019
@ -37,18 +37,18 @@ jobs:
- os: windows-2019 - os: windows-2019
build_type: x86-Release build_type: x86-Release
arch: amd64_x86 arch: amd64_x86
- os: windows-2019
build_type: x86-Debug-Clang
arch: amd64_x86
- os: windows-2019
build_type: x86-Release-Clang
arch: amd64_x86
- os: windows-2022 - os: windows-2022
build_type: x86-Debug build_type: x86-Debug
arch: amd64_x86 arch: amd64_x86
- os: windows-2022 - os: windows-2022
build_type: x86-Release build_type: x86-Release
arch: amd64_x86 arch: amd64_x86
- os: windows-2022
build_type: x64-Debug-Clang
arch: amd64
- os: windows-2022
build_type: x64-Release-Clang
arch: amd64
- os: windows-2022 - os: windows-2022
build_type: x86-Debug-Clang build_type: x86-Debug-Clang
arch: amd64_x86 arch: amd64_x86

View File

@ -33,7 +33,7 @@ jobs:
matrix: matrix:
os: [windows-2019, windows-2022] os: [windows-2019, windows-2022]
build_type: [x64-Debug, x64-Release, x64-Debug-Clang, x64-Release-Clang] build_type: [x64-Debug, x64-Release]
arch: [amd64] arch: [amd64]
include: include:
- os: windows-2019 - os: windows-2019
@ -54,6 +54,9 @@ jobs:
- os: windows-2022 - os: windows-2022
build_type: x86-Release build_type: x86-Release
arch: amd64_x86 arch: amd64_x86
- os: windows-2022
build_type: x64-Release-Clang
arch: amd64
- os: windows-2022 - os: windows-2022
build_type: x86-Debug-Clang build_type: x86-Debug-Clang
arch: amd64_x86 arch: amd64_x86
@ -76,6 +79,7 @@ jobs:
# Exclude failing case due to linker issue. # Exclude failing case due to linker issue.
- os: windows-2022 - os: windows-2022
build_type: x64-Debug-Clang build_type: x64-Debug-Clang
arch: amd64
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -125,13 +129,13 @@ jobs:
with: with:
runVcpkgInstall: true runVcpkgInstall: true
vcpkgJsonGlob: '**/build/vcpkg.json' vcpkgJsonGlob: '**/build/vcpkg.json'
vcpkgGitCommitId: 'cacf5994341f27e9a14a7b8724b0634b138ecb30' vcpkgGitCommitId: '7516a02de04e8f8ff4e4beb8f5bac0565f9bf9da'
- name: 'Configure CMake' - name: 'Configure CMake'
working-directory: ${{ github.workspace }} working-directory: ${{ github.workspace }}
shell: pwsh shell: pwsh
run: > run: >
cmake --preset=${{ matrix.build_type }} -DBUILD_TOOLS=ON -DBUILD_TESTING=ON cmake --preset=${{ matrix.build_type }} -DBUILD_TESTING=ON
-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_MANIFEST_DIR="${{ github.workspace }}/build" -DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_MANIFEST_DIR="${{ github.workspace }}/build"
-DVCPKG_TARGET_TRIPLET="${env:VCPKG_DEFAULT_TRIPLET}" -DVCPKG_TARGET_TRIPLET="${env:VCPKG_DEFAULT_TRIPLET}"

94
.github/workflows/vcpkg.yml vendored Normal file
View File

@ -0,0 +1,94 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkID=512686
name: 'CMake (Windows using VCPKG)'
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
paths-ignore:
- '*.md'
- LICENSE
- build/*
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2019, windows-2022]
build_type: [x64-Debug-VCPKG]
arch: [amd64]
include:
- os: windows-2022
build_type: x86-Debug-VCPKG
arch: amd64_x86
- os: windows-2022
build_type: arm64-Debug-VCPKG
arch: amd64_arm64
exclude:
# Exclude failing case due to linker issue.
- os: windows-2022
build_type: x64-Debug-Clang-VCPKG
arch: amd64
steps:
- uses: actions/checkout@v4
- name: 'Install Ninja'
run: choco install ninja
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
- name: 'Set triplet'
shell: pwsh
run: |
if ("${{ matrix.arch }}" -eq "amd64")
{
echo "VCPKG_DEFAULT_TRIPLET=x64-windows" >> $env:GITHUB_ENV
}
elseif ("${{ matrix.arch }}" -eq "amd64_x86")
{
echo "VCPKG_DEFAULT_TRIPLET=x86-windows" >> $env:GITHUB_ENV
}
elseif ("${{ matrix.arch }}" -eq "amd64_arm64")
{
if ("${{ matrix.build_type }}" -match "^arm64ec")
{
echo "VCPKG_DEFAULT_TRIPLET=arm64ec-windows" >> $env:GITHUB_ENV
}
else
{
echo "VCPKG_DEFAULT_TRIPLET=arm64-windows" >> $env:GITHUB_ENV
}
}
else
{
echo "::error Unknown architecture/build-type triplet mapping"
}
- uses: lukka/run-vcpkg@v11
with:
runVcpkgInstall: true
vcpkgJsonGlob: '**/build/vcpkg.json'
vcpkgGitCommitId: '7516a02de04e8f8ff4e4beb8f5bac0565f9bf9da'
- name: 'Configure CMake'
working-directory: ${{ github.workspace }}
run: >
cmake --preset=${{ matrix.build_type }} -DBUILD_TESTING=OFF -DBUILD_TOOLS=ON -DENABLE_USE_EIGEN=ON
-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_MANIFEST_DIR="${{ github.workspace }}/build"
-DVCPKG_TARGET_TRIPLET="${env:VCPKG_DEFAULT_TRIPLET}"
- name: 'Build'
working-directory: ${{ github.workspace }}
run: cmake --build out\build\${{ matrix.build_type }}

View File

@ -228,12 +228,12 @@
{ "name": "arm64-Debug-UWP-Clang" , "description": "Clang/LLVM for AArch64 (Debug) for UWP", "inherits": [ "base", "ARM64", "Debug", "Clang", "UWP" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } }, { "name": "arm64-Debug-UWP-Clang" , "description": "Clang/LLVM for AArch64 (Debug) for UWP", "inherits": [ "base", "ARM64", "Debug", "Clang", "UWP" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } },
{ "name": "arm64-Release-UWP-Clang", "description": "Clang/LLVM for AArch64 (Release) for UWP", "inherits": [ "base", "ARM64", "Release", "Clang", "UWP" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } }, { "name": "arm64-Release-UWP-Clang", "description": "Clang/LLVM for AArch64 (Release) for UWP", "inherits": [ "base", "ARM64", "Release", "Clang", "UWP" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } },
{ "name": "x64-Debug-VCPKG-Clang" , "description": "Clang/LLVM for x64 (Debug) uvatlastool", "inherits": [ "base", "x64", "Debug", "VCPKG", "Clang", "Tools" ] }, { "name": "x64-Debug-Clang-VCPKG" , "description": "Clang/LLVM for x64 (Debug) uvatlastool", "inherits": [ "base", "x64", "Debug", "VCPKG", "Clang", "Tools" ] },
{ "name": "x64-Release-VCPKG-Clang" , "description": "Clang/LLVM for x64 (Release) uvatlastool", "inherits": [ "base", "x64", "Release", "VCPKG", "Clang", "Tools" ] }, { "name": "x64-Release-Clang-VCPKG" , "description": "Clang/LLVM for x64 (Release) uvatlastool", "inherits": [ "base", "x64", "Release", "VCPKG", "Clang", "Tools" ] },
{ "name": "x86-Debug-VCPKG-Clang" , "description": "Clang/LLVM for x86 (Debug) uvatlastool", "inherits": [ "base", "x86", "Debug", "VCPKG", "Clang", "Tools" ], "environment": { "CXXFLAGS": "-m32" } }, { "name": "x86-Debug-Clang-VCPKG" , "description": "Clang/LLVM for x86 (Debug) uvatlastool", "inherits": [ "base", "x86", "Debug", "VCPKG", "Clang", "Tools" ], "environment": { "CXXFLAGS": "-m32" } },
{ "name": "x86-Release-VCPKG-Clang" , "description": "Clang/LLVM for x86 (Release) uvatlastool", "inherits": [ "base", "x86", "Release", "VCPKG", "Clang", "Tools" ], "environment": { "CXXFLAGS": "-m32" } }, { "name": "x86-Release-Clang-VCPKG" , "description": "Clang/LLVM for x86 (Release) uvatlastool", "inherits": [ "base", "x86", "Release", "VCPKG", "Clang", "Tools" ], "environment": { "CXXFLAGS": "-m32" } },
{ "name": "arm64-Debug-VCPKG-Clang" , "description": "Clang/LLVM for AArch64 (Debug) uvatlastool", "inherits": [ "base", "ARM64", "Debug", "VCPKG", "Clang", "Tools" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } }, { "name": "arm64-Debug-Clang-VCPKG" , "description": "Clang/LLVM for AArch64 (Debug) uvatlastool", "inherits": [ "base", "ARM64", "Debug", "VCPKG", "Clang", "Tools" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } },
{ "name": "arm64-Release-VCPKG-Clang", "description": "Clang/LLVM for AArch64 (Release) uvatlastool", "inherits": [ "base", "ARM64", "Release", "VCPKG", "Clang", "Tools" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } }, { "name": "arm64-Release-Clang-VCPKG", "description": "Clang/LLVM for AArch64 (Release) uvatlastool", "inherits": [ "base", "ARM64", "Release", "VCPKG", "Clang", "Tools" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } },
{ "name": "x64-Debug-Scarlett-Clang" , "description": "Clang/LLVM for x64 (Debug) for Xbox Series X|S", "inherits": [ "base", "x64", "Debug", "Clang", "Scarlett" ] }, { "name": "x64-Debug-Scarlett-Clang" , "description": "Clang/LLVM for x64 (Debug) for Xbox Series X|S", "inherits": [ "base", "x64", "Debug", "Clang", "Scarlett" ] },
{ "name": "x64-Release-Scarlett-Clang", "description": "Clang/LLVM for x64 (Release) for Xbox Series X|S", "inherits": [ "base", "x64", "Release", "Clang", "Scarlett" ] }, { "name": "x64-Release-Scarlett-Clang", "description": "Clang/LLVM for x64 (Release) for Xbox Series X|S", "inherits": [ "base", "x64", "Release", "Clang", "Scarlett" ] },

View File

@ -136,7 +136,8 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
list(APPEND COMPILER_SWITCHES /Zc:lambda) list(APPEND COMPILER_SWITCHES /Zc:lambda)
endif() endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.29) if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.29)
AND (NOT VCPKG_TOOLCHAIN))
list(APPEND COMPILER_SWITCHES /external:W4) list(APPEND COMPILER_SWITCHES /external:W4)
endif() endif()