chore(cmake): update vcpkg configuration and toolchain for Windows

- Modified CMake presets to include static triplet for vcpkg in Windows configurations, enhancing build consistency.
- Updated vcpkg baseline and commit ID across configuration files to ensure compatibility with the latest package versions.
- Enhanced CI workflows to utilize the new vcpkg toolchain file, improving the setup process for Windows builds.

Benefits:
- Ensures the project leverages the latest features and fixes from vcpkg, enhancing overall stability.
- Streamlines the Windows build process by consolidating vcpkg configurations, reducing potential discrepancies during builds.
This commit is contained in:
scawful
2025-10-15 22:42:56 -04:00
parent 1490578ed6
commit 5acda67016
11 changed files with 210 additions and 25 deletions

View File

@@ -79,19 +79,39 @@ jobs:
VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite'
with:
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
vcpkgGitCommitId: '8eb57355a4ffb410a2e94c07b4dca2dffbee8e50' # November 2024 release
vcpkgGitCommitId: '7ba0ba7334c3346e7eee1e049ba85da193a8d821' # 2025.01.20 release
runVcpkgInstall: false # Let CMake handle installation via manifest mode
- name: Retry vcpkg setup (Windows)
if: runner.os == 'Windows' && steps.vcpkg.outcome == 'failure'
uses: lukka/run-vcpkg@v11
id: vcpkg_retry
env:
VCPKG_DEFAULT_TRIPLET: x64-windows-static
VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite'
with:
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
vcpkgGitCommitId: '7ba0ba7334c3346e7eee1e049ba85da193a8d821'
runVcpkgInstall: false
- name: Resolve vcpkg toolchain (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
# Try to get vcpkg root from either initial setup or retry
$vcpkgRoot = "${{ steps.vcpkg.outputs.vcpkgRoot }}"
if (-not $vcpkgRoot) {
$vcpkgRoot = "${{ steps.vcpkg_retry.outputs.vcpkgRoot }}"
}
if (-not $vcpkgRoot) {
$vcpkgRoot = Join-Path "${{ github.workspace }}" "vcpkg"
}
Write-Host "Checking vcpkg root: $vcpkgRoot"
if (-not (Test-Path $vcpkgRoot)) {
Write-Host "::error::vcpkg root not found at $vcpkgRoot"
Write-Host "vcpkg setup status: ${{ steps.vcpkg.outcome }}"
Write-Host "vcpkg retry status: ${{ steps.vcpkg_retry.outcome }}"
exit 1
}
@@ -104,6 +124,9 @@ jobs:
$normalizedRoot = $vcpkgRoot -replace '\\', '/'
$normalizedToolchain = $toolchain -replace '\\', '/'
Write-Host "✓ vcpkg root: $normalizedRoot"
Write-Host "✓ Toolchain: $normalizedToolchain"
"VCPKG_ROOT=$normalizedRoot" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"CMAKE_TOOLCHAIN_FILE=$normalizedToolchain" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
@@ -130,24 +153,37 @@ jobs:
arch: x64
- name: Diagnose vcpkg (Windows)
if: runner.os == 'Windows' && (steps.vcpkg.outcome == 'failure' || steps.vcpkg.outcome == 'success')
if: runner.os == 'Windows'
shell: pwsh
run: |
Write-Host "=== vcpkg Diagnostics ===" -ForegroundColor Cyan
Write-Host "Initial setup: ${{ steps.vcpkg.outcome }}"
Write-Host "Retry setup: ${{ steps.vcpkg_retry.outcome }}"
Write-Host "vcpkg directory: ${{ github.workspace }}/vcpkg"
if (Test-Path "${{ github.workspace }}/vcpkg/vcpkg.exe") {
Write-Host "✅ vcpkg.exe found" -ForegroundColor Green
& "${{ github.workspace }}/vcpkg/vcpkg.exe" version
Write-Host "`nvcpkg installed packages:" -ForegroundColor Cyan
& "${{ github.workspace }}/vcpkg/vcpkg.exe" list | Select-Object -First 20
} else {
Write-Host "❌ vcpkg.exe not found" -ForegroundColor Red
}
Write-Host "CMAKE_TOOLCHAIN_FILE: $env:CMAKE_TOOLCHAIN_FILE"
Write-Host "`nEnvironment:" -ForegroundColor Cyan
Write-Host "CMAKE_TOOLCHAIN_FILE: $env:CMAKE_TOOLCHAIN_FILE"
Write-Host "VCPKG_DEFAULT_TRIPLET: $env:VCPKG_DEFAULT_TRIPLET"
Write-Host "VCPKG_ROOT: $env:VCPKG_ROOT"
Write-Host "Workspace: ${{ github.workspace }}"
Write-Host "`nManifest files:" -ForegroundColor Cyan
if (Test-Path "vcpkg.json") {
Write-Host "✅ vcpkg.json found"
Get-Content "vcpkg.json" | Write-Host
}
if (Test-Path "vcpkg-configuration.json") {
Write-Host "✅ vcpkg-configuration.json found"
}
- name: Restore ccache
uses: actions/cache@v4
@@ -294,8 +330,7 @@ jobs:
"-DYAZE_BUILD_EMU=ON",
"-DYAZE_BUILD_Z3ED=ON",
"-DYAZE_BUILD_TOOLS=ON",
"-DYAZE_ENABLE_ROM_TESTS=OFF",
"-DVCPKG_INSTALL_OPTIONS=--x-feature=pkgconfig"
"-DYAZE_ENABLE_ROM_TESTS=OFF"
)
cmake @cmakeArgs 2>&1 | Tee-Object -FilePath cmake_config.log

View File

@@ -30,7 +30,7 @@ jobs:
uses: lukka/run-vcpkg@v11
with:
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
vcpkgGitCommitId: '8eb57355a4ffb410a2e94c07b4dca2dffbee8e50'
vcpkgGitCommitId: '7ba0ba7334c3346e7eee1e049ba85da193a8d821'
runVcpkgInstall: false
env:
VCPKG_DEFAULT_TRIPLET: x64-windows-static
@@ -58,8 +58,7 @@ jobs:
-DYAZE_BUILD_TESTS=OFF `
-DYAZE_BUILD_EMU=ON `
-DYAZE_BUILD_Z3ED=ON `
-DYAZE_BUILD_TOOLS=ON `
-DVCPKG_INSTALL_OPTIONS="--x-feature=pkgconfig"
-DYAZE_BUILD_TOOLS=ON
- name: Build
run: cmake --build build --config Release --parallel 4 -- /p:CL_MPcount=4

View File

@@ -68,7 +68,7 @@
{
"name": "_win",
"hidden": true,
"description": "Windows base configuration",
"description": "Windows base configuration with vcpkg static triplet",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
@@ -77,7 +77,8 @@
"generator": "Visual Studio 17 2022",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake",
"VCPKG_MANIFEST_MODE": "ON"
"VCPKG_MANIFEST_MODE": "ON",
"VCPKG_TARGET_TRIPLET": "x64-windows-static"
}
},
{
@@ -193,34 +194,31 @@
{
"name": "win-dbg",
"displayName": "Windows Debug (x64)",
"description": "Windows x64 debug build (warnings off)",
"description": "Windows x64 debug build with static vcpkg (warnings off)",
"inherits": ["_base", "_win", "_quiet"],
"architecture": "x64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"VCPKG_TARGET_TRIPLET": "x64-windows"
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "win-dbg-v",
"displayName": "Windows Debug Verbose (x64)",
"description": "Windows x64 debug build with all warnings",
"description": "Windows x64 debug build with static vcpkg and all warnings",
"inherits": ["_base", "_win", "_verbose"],
"architecture": "x64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"VCPKG_TARGET_TRIPLET": "x64-windows"
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "win-rel",
"displayName": "Windows Release (x64)",
"description": "Windows x64 release build (warnings off)",
"description": "Windows x64 release build with static vcpkg (warnings off)",
"inherits": ["_base", "_win", "_quiet"],
"architecture": "x64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"VCPKG_TARGET_TRIPLET": "x64-windows",
"YAZE_BUILD_TESTS": "OFF"
}
},

View File

@@ -9,6 +9,17 @@ include(FetchContent)
if(WIN32)
include(${CMAKE_CURRENT_LIST_DIR}/grpc_windows.cmake)
if(YAZE_GRPC_CONFIGURED)
# Validate that grpc_windows.cmake properly exported required targets/variables
if(NOT COMMAND target_add_protobuf)
message(FATAL_ERROR "grpc_windows.cmake did not define target_add_protobuf function")
endif()
if(NOT DEFINED ABSL_TARGETS OR NOT ABSL_TARGETS)
message(FATAL_ERROR "grpc_windows.cmake did not export ABSL_TARGETS")
endif()
if(NOT DEFINED YAZE_PROTOBUF_TARGETS OR NOT YAZE_PROTOBUF_TARGETS)
message(FATAL_ERROR "grpc_windows.cmake did not export YAZE_PROTOBUF_TARGETS")
endif()
message(STATUS "✓ Windows vcpkg gRPC configuration validated")
return()
endif()
endif()

View File

@@ -63,13 +63,113 @@ if(WIN32 AND YAZE_USE_VCPKG_GRPC)
endif()
# Set variables for compatibility with rest of build system
set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE $<TARGET_FILE:protoc>)
set(_gRPC_CPP_PLUGIN $<TARGET_FILE:grpc_cpp_plugin>)
set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE $<TARGET_FILE:protoc> PARENT_SCOPE)
set(_gRPC_CPP_PLUGIN $<TARGET_FILE:grpc_cpp_plugin> PARENT_SCOPE)
set(_gRPC_PROTO_GENS_DIR ${CMAKE_BINARY_DIR}/gens)
file(MAKE_DIRECTORY ${_gRPC_PROTO_GENS_DIR})
set(_gRPC_PROTO_GENS_DIR ${_gRPC_PROTO_GENS_DIR} PARENT_SCOPE)
# Export Abseil targets from vcpkg (critical for linking!)
set(ABSL_TARGETS
absl::base
absl::config
absl::core_headers
absl::utility
absl::memory
absl::container_memory
absl::strings
absl::str_format
absl::cord
absl::hash
absl::time
absl::status
absl::statusor
absl::flags
absl::flags_parse
absl::flags_usage
absl::flags_commandlineflag
absl::flags_marshalling
absl::flags_private_handle_accessor
absl::flags_program_name
absl::flags_config
absl::flags_reflection
absl::examine_stack
absl::stacktrace
absl::failure_signal_handler
absl::flat_hash_map
absl::synchronization
absl::symbolize
PARENT_SCOPE
)
# Export protobuf targets
set(YAZE_PROTOBUF_TARGETS protobuf::libprotobuf PARENT_SCOPE)
set(YAZE_PROTOBUF_WHOLEARCHIVE_TARGETS protobuf::libprotobuf PARENT_SCOPE)
# Get protobuf include directories for proto generation
get_target_property(_PROTOBUF_INCLUDE_DIRS protobuf::libprotobuf
INTERFACE_INCLUDE_DIRECTORIES)
if(_PROTOBUF_INCLUDE_DIRS)
list(GET _PROTOBUF_INCLUDE_DIRS 0 _gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR)
set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR} PARENT_SCOPE)
endif()
# Define target_add_protobuf() function for proto compilation (needed by vcpkg path)
function(target_add_protobuf target)
if(NOT TARGET ${target})
message(FATAL_ERROR "Target ${target} doesn't exist")
endif()
if(NOT ARGN)
message(SEND_ERROR "Error: target_add_protobuf() called without any proto files")
return()
endif()
set(_protobuf_include_path -I . -I ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR})
foreach(FIL ${ARGN})
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
get_filename_component(FIL_WE ${FIL} NAME_WE)
file(RELATIVE_PATH REL_FIL ${CMAKE_CURRENT_SOURCE_DIR} ${ABS_FIL})
get_filename_component(REL_DIR ${REL_FIL} DIRECTORY)
if(NOT REL_DIR)
set(RELFIL_WE "${FIL_WE}")
else()
set(RELFIL_WE "${REL_DIR}/${FIL_WE}")
endif()
add_custom_command(
OUTPUT "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.cc"
"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.h"
"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}_mock.grpc.pb.h"
"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.cc"
"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.h"
COMMAND ${_gRPC_PROTOBUF_PROTOC_EXECUTABLE}
ARGS --grpc_out=generate_mock_code=true:${_gRPC_PROTO_GENS_DIR}
--cpp_out=${_gRPC_PROTO_GENS_DIR}
--plugin=protoc-gen-grpc=${_gRPC_CPP_PLUGIN}
${_protobuf_include_path}
${REL_FIL}
DEPENDS ${ABS_FIL} protoc grpc_cpp_plugin
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Running gRPC C++ protocol buffer compiler on ${FIL}"
VERBATIM)
target_sources(${target} PRIVATE
"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.cc"
"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.h"
"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}_mock.grpc.pb.h"
"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.cc"
"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.h"
)
target_include_directories(${target} PUBLIC
$<BUILD_INTERFACE:${_gRPC_PROTO_GENS_DIR}>
$<BUILD_INTERFACE:${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR}>
)
endforeach()
endfunction()
# Skip the FetchContent path
set(YAZE_GRPC_CONFIGURED TRUE PARENT_SCOPE)
message(STATUS "gRPC setup complete via vcpkg (includes bundled Abseil)")
return()
else()
message(WARNING "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")

View File

@@ -1,6 +1,9 @@
# SDL2
# On Windows with vcpkg, prefer vcpkg packages for faster builds
if(WIN32)
# Disable pkgconfig for SDL on Windows (prevents MSYS2 download failures in vcpkg)
set(SDL_PKGCONFIG OFF CACHE BOOL "Disable pkgconfig on Windows" FORCE)
# Try to find SDL2 via vcpkg first if toolchain is available
if(DEFINED CMAKE_TOOLCHAIN_FILE AND EXISTS "${CMAKE_TOOLCHAIN_FILE}")
find_package(SDL2 CONFIG QUIET)

View File

@@ -0,0 +1,37 @@
# Windows vcpkg toolchain wrapper
# This file provides a convenient way to configure vcpkg for Windows builds
#
# Usage:
# cmake -DCMAKE_TOOLCHAIN_FILE=cmake/windows-vcpkg.toolchain.cmake ..
#
# Or set VCPKG_ROOT environment variable and this will find it automatically
# Set vcpkg triplet for static Windows builds
set(VCPKG_TARGET_TRIPLET "x64-windows-static" CACHE STRING "vcpkg triplet")
set(VCPKG_HOST_TRIPLET "x64-windows" CACHE STRING "vcpkg host triplet")
# Enable manifest mode
set(VCPKG_MANIFEST_MODE ON CACHE BOOL "Use vcpkg manifest mode")
# Find vcpkg root
if(DEFINED ENV{VCPKG_ROOT} AND EXISTS "$ENV{VCPKG_ROOT}")
set(VCPKG_ROOT "$ENV{VCPKG_ROOT}" CACHE PATH "vcpkg root directory")
elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../vcpkg/scripts/buildsystems/vcpkg.cmake")
set(VCPKG_ROOT "${CMAKE_CURRENT_LIST_DIR}/../vcpkg" CACHE PATH "vcpkg root directory")
else()
message(WARNING "vcpkg not found. Set VCPKG_ROOT environment variable or clone vcpkg to project root.")
message(WARNING " git clone https://github.com/Microsoft/vcpkg.git")
message(WARNING " cd vcpkg && bootstrap-vcpkg.bat")
return()
endif()
# Include the vcpkg toolchain
set(VCPKG_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
if(EXISTS "${VCPKG_TOOLCHAIN_FILE}")
message(STATUS "Using vcpkg toolchain: ${VCPKG_TOOLCHAIN_FILE}")
message(STATUS " Triplet: ${VCPKG_TARGET_TRIPLET}")
include("${VCPKG_TOOLCHAIN_FILE}")
else()
message(FATAL_ERROR "vcpkg toolchain not found at ${VCPKG_TOOLCHAIN_FILE}")
endif()

View File

@@ -108,12 +108,14 @@ if(YAZE_WITH_GRPC)
${CMAKE_SOURCE_DIR}/third_party/json/include)
target_compile_definitions(yaze_app_core_lib PRIVATE YAZE_WITH_JSON)
# Add proto definitions for ROM service and canvas automation
# NOTE: Test harness proto is in test.cmake with yaze_test_support
# Add proto definitions for ROM service, canvas automation, and test harness
# Test harness proto is needed because widget_discovery_service.h includes it
target_add_protobuf(yaze_app_core_lib
${PROJECT_SOURCE_DIR}/src/protos/rom_service.proto)
target_add_protobuf(yaze_app_core_lib
${PROJECT_SOURCE_DIR}/src/protos/canvas_automation.proto)
target_add_protobuf(yaze_app_core_lib
${PROJECT_SOURCE_DIR}/src/protos/imgui_test_harness.proto)
# Add unified gRPC server (non-test services only)
target_sources(yaze_app_core_lib PRIVATE

View File

@@ -3,7 +3,7 @@
"default-registry": {
"kind": "git",
"repository": "https://github.com/microsoft/vcpkg",
"baseline": "8eb57355a4ffb410a2e94c07b4dca2dffbee8e50"
"baseline": "7ba0ba7334c3346e7eee1e049ba85da193a8d821"
},
"registries": []
}

View File

@@ -3,7 +3,7 @@
"name": "yaze",
"version": "0.3.2",
"description": "Yet Another Zelda3 Editor",
"builtin-baseline": "8eb57355a4ffb410a2e94c07b4dca2dffbee8e50",
"builtin-baseline": "7ba0ba7334c3346e7eee1e049ba85da193a8d821",
"dependencies": [
{
"name": "sdl2",