Enhance CMake and vcpkg integration for Windows ARM64 builds
- Updated `CMakeLists.txt` to improve vcpkg integration by adding checks for the existence of the toolchain file and providing warnings if it is not found. - Introduced new CMake presets for Windows ARM64 configurations (debug, release, and development) in `CMakePresets.json`, ensuring proper setup for ARM64 architecture. - Modified `setup-vcpkg-windows.ps1` to auto-detect ARM64 architecture, enhancing the setup script's usability for different environments.
This commit is contained in:
@@ -93,12 +93,22 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
set(YAZE_PLATFORM_WINDOWS ON)
|
||||
# Enable vcpkg integration for Windows builds
|
||||
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||
CACHE STRING "Vcpkg toolchain file")
|
||||
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake" AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake"
|
||||
CACHE STRING "Vcpkg toolchain file")
|
||||
# Check if CMAKE_TOOLCHAIN_FILE is set but the file doesn't exist
|
||||
if(DEFINED CMAKE_TOOLCHAIN_FILE AND NOT EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
||||
message(WARNING "vcpkg toolchain file specified but not found: ${CMAKE_TOOLCHAIN_FILE}")
|
||||
message(WARNING "Disabling vcpkg integration. Install vcpkg or set VCPKG_ROOT environment variable.")
|
||||
unset(CMAKE_TOOLCHAIN_FILE CACHE)
|
||||
endif()
|
||||
|
||||
# Set vcpkg toolchain file if not already set or if the previous one was invalid
|
||||
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||
if(DEFINED ENV{VCPKG_ROOT})
|
||||
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||
CACHE STRING "Vcpkg toolchain file")
|
||||
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")
|
||||
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake"
|
||||
CACHE STRING "Vcpkg toolchain file")
|
||||
endif()
|
||||
endif()
|
||||
# Setup yaze_config include directories
|
||||
|
||||
@@ -115,7 +125,13 @@ elseif(YAZE_PLATFORM_MACOS)
|
||||
set(CMAKE_INSTALL_PREFIX /usr/local)
|
||||
target_compile_definitions(yaze_common INTERFACE MACOS)
|
||||
elseif(YAZE_PLATFORM_WINDOWS)
|
||||
include(cmake/vcpkg.cmake)
|
||||
# Only include vcpkg configuration if vcpkg toolchain is available
|
||||
if(DEFINED CMAKE_TOOLCHAIN_FILE AND EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
||||
include(cmake/vcpkg.cmake)
|
||||
message(STATUS "Using vcpkg integration")
|
||||
else()
|
||||
message(STATUS "vcpkg not available - using system packages")
|
||||
endif()
|
||||
target_compile_definitions(yaze_common INTERFACE WINDOWS)
|
||||
|
||||
# Windows-specific architecture detection and configuration
|
||||
|
||||
@@ -219,6 +219,62 @@
|
||||
"YAZE_ENABLE_ROM_TESTS": "ON"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-arm64-debug",
|
||||
"displayName": "Windows ARM64 Debug",
|
||||
"description": "Windows ARM64-specific debug configuration with vcpkg",
|
||||
"inherits": "debug",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Windows"
|
||||
},
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"architecture": "arm64",
|
||||
"cacheVariables": {
|
||||
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake",
|
||||
"VCPKG_TARGET_TRIPLET": "arm64-windows",
|
||||
"VCPKG_MANIFEST_MODE": "ON"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-arm64-release",
|
||||
"displayName": "Windows ARM64 Release",
|
||||
"description": "Windows ARM64-specific release configuration with vcpkg",
|
||||
"inherits": "release",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Windows"
|
||||
},
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"architecture": "arm64",
|
||||
"cacheVariables": {
|
||||
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake",
|
||||
"VCPKG_TARGET_TRIPLET": "arm64-windows",
|
||||
"VCPKG_MANIFEST_MODE": "ON"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-arm64-dev",
|
||||
"displayName": "Windows ARM64 Development",
|
||||
"description": "Windows ARM64 development build with vcpkg and testing enabled",
|
||||
"inherits": "debug",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Windows"
|
||||
},
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"architecture": "arm64",
|
||||
"cacheVariables": {
|
||||
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake",
|
||||
"VCPKG_TARGET_TRIPLET": "arm64-windows",
|
||||
"VCPKG_MANIFEST_MODE": "ON",
|
||||
"YAZE_BUILD_TESTS": "ON",
|
||||
"YAZE_ENABLE_ROM_TESTS": "ON"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "asan",
|
||||
"displayName": "AddressSanitizer",
|
||||
@@ -314,6 +370,21 @@
|
||||
"name": "windows-dev",
|
||||
"configurePreset": "windows-dev",
|
||||
"displayName": "Windows Development Build"
|
||||
},
|
||||
{
|
||||
"name": "windows-arm64-debug",
|
||||
"configurePreset": "windows-arm64-debug",
|
||||
"displayName": "Windows ARM64 Debug Build"
|
||||
},
|
||||
{
|
||||
"name": "windows-arm64-release",
|
||||
"configurePreset": "windows-arm64-release",
|
||||
"displayName": "Windows ARM64 Release Build"
|
||||
},
|
||||
{
|
||||
"name": "windows-arm64-dev",
|
||||
"configurePreset": "windows-arm64-dev",
|
||||
"displayName": "Windows ARM64 Development Build"
|
||||
}
|
||||
],
|
||||
"testPresets": [
|
||||
|
||||
@@ -5,6 +5,15 @@ param(
|
||||
[string]$Triplet = "x64-windows"
|
||||
)
|
||||
|
||||
# Auto-detect architecture if not specified
|
||||
if ($Triplet -eq "x64-windows") {
|
||||
$Architecture = $env:PROCESSOR_ARCHITECTURE
|
||||
if ($Architecture -eq "ARM64") {
|
||||
$Triplet = "arm64-windows"
|
||||
Write-Host "Auto-detected ARM64 architecture, using arm64-windows triplet" -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
|
||||
# Set error handling
|
||||
$ErrorActionPreference = "Continue"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user