diff --git a/CMakeLists.txt b/CMakeLists.txt index 530f56ec..ebac79b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/CMakePresets.json b/CMakePresets.json index 89c978c5..f5a62a61 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -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": [ diff --git a/scripts/setup-vcpkg-windows.ps1 b/scripts/setup-vcpkg-windows.ps1 index bfb3e2eb..d75821e0 100644 --- a/scripts/setup-vcpkg-windows.ps1 +++ b/scripts/setup-vcpkg-windows.ps1 @@ -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"