Enhance CMake configuration and project generation scripts

- Added policies for submodule compatibility and suppressed deprecation warnings in CMakeLists.txt.
- Updated Visual Studio project generation scripts to include new CMake arguments for policy versions and thread handling.
- Introduced a new PowerShell script to test CMake configuration, ensuring successful setup and providing user feedback.
This commit is contained in:
scawful
2025-09-27 23:58:08 -04:00
parent 188084b59e
commit 3af69c5ae2
4 changed files with 114 additions and 1 deletions

View File

@@ -7,6 +7,25 @@ if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()
# Set additional policies to handle submodule compatibility
if(POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif()
if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()
# Suppress deprecation warnings from submodules
set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "Suppress deprecation warnings")
# Handle pthread issues on Windows
if(WIN32)
set(THREADS_PREFER_PTHREAD_FLAG OFF)
endif()
project(yaze VERSION 0.3.1
DESCRIPTION "Yet Another Zelda3 Editor"
LANGUAGES CXX C)

View File

@@ -124,7 +124,7 @@ if exist "%VCPKG_PATH%" (
)
REM Build CMake command
set CMAKE_ARGS=-B "%BUILD_DIR%" -G "Visual Studio 17 2022" -A %ARCHITECTURE% -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DYAZE_BUILD_TESTS=ON -DYAZE_BUILD_APP=ON -DYAZE_BUILD_LIB=ON -DYAZE_BUILD_EMU=ON -DYAZE_BUILD_Z3ED=ON -DYAZE_ENABLE_ROM_TESTS=OFF -DYAZE_ENABLE_EXPERIMENTAL_TESTS=ON -DYAZE_ENABLE_UI_TESTS=ON -DYAZE_INSTALL_LIB=OFF
set CMAKE_ARGS=-B "%BUILD_DIR%" -G "Visual Studio 17 2022" -A %ARCHITECTURE% -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_POLICY_VERSION_MAXIMUM=3.28 -DCMAKE_WARN_DEPRECATED=OFF -DABSL_PROPAGATE_CXX_STD=ON -DTHREADS_PREFER_PTHREAD_FLAG=OFF -DYAZE_BUILD_TESTS=ON -DYAZE_BUILD_APP=ON -DYAZE_BUILD_LIB=ON -DYAZE_BUILD_EMU=ON -DYAZE_BUILD_Z3ED=ON -DYAZE_ENABLE_ROM_TESTS=OFF -DYAZE_ENABLE_EXPERIMENTAL_TESTS=ON -DYAZE_ENABLE_UI_TESTS=ON -DYAZE_INSTALL_LIB=OFF
if "%USE_VCPKG%"=="true" (
set CMAKE_ARGS=%CMAKE_ARGS% -DCMAKE_TOOLCHAIN_FILE="%VCPKG_PATH%" -DVCPKG_TARGET_TRIPLET=%ARCHITECTURE%-windows -DVCPKG_MANIFEST_MODE=ON

View File

@@ -136,6 +136,11 @@ $CmakeArgs = @(
"-G", "`"$Generator`"",
$ArchFlag,
"-DCMAKE_BUILD_TYPE=$Configuration",
"-DCMAKE_POLICY_VERSION_MINIMUM=3.5",
"-DCMAKE_POLICY_VERSION_MAXIMUM=3.28",
"-DCMAKE_WARN_DEPRECATED=OFF",
"-DABSL_PROPAGATE_CXX_STD=ON",
"-DTHREADS_PREFER_PTHREAD_FLAG=OFF",
"-DYAZE_BUILD_TESTS=ON",
"-DYAZE_BUILD_APP=ON",
"-DYAZE_BUILD_LIB=ON",

View File

@@ -0,0 +1,89 @@
# Test CMake configuration for YAZE
# This script tests if CMake can configure the project without errors
param(
[string]$Architecture = "x64",
[switch]$Clean = $false
)
Write-Host "Testing CMake configuration for YAZE..." -ForegroundColor Green
# Check if we're on Windows
if ($env:OS -ne "Windows_NT") {
Write-Host "This script is designed for Windows only." -ForegroundColor Red
exit 1
}
# Check if CMake is available
$cmakePath = Get-Command cmake -ErrorAction SilentlyContinue
if (-not $cmakePath) {
Write-Host "CMake not found. Please run setup-windows-dev.ps1 first." -ForegroundColor Red
exit 1
}
Write-Host "CMake found: $($cmakePath.Source)" -ForegroundColor Green
# Set up paths
$SourceDir = Split-Path -Parent $PSScriptRoot
$TestBuildDir = Join-Path $SourceDir "build-test"
Write-Host "Source directory: $SourceDir" -ForegroundColor Cyan
Write-Host "Test build directory: $TestBuildDir" -ForegroundColor Cyan
# Clean test build directory if requested
if ($Clean -and (Test-Path $TestBuildDir)) {
Write-Host "Cleaning test build directory..." -ForegroundColor Yellow
Remove-Item -Recurse -Force $TestBuildDir
}
# Create test build directory
if (-not (Test-Path $TestBuildDir)) {
New-Item -ItemType Directory -Path $TestBuildDir | Out-Null
}
# Test CMake configuration with minimal settings
Write-Host "Testing CMake configuration..." -ForegroundColor Yellow
$TestArgs = @(
"-B", $TestBuildDir,
"-G", "Visual Studio 17 2022",
"-A", $Architecture,
"-DCMAKE_BUILD_TYPE=Debug",
"-DCMAKE_POLICY_VERSION_MINIMUM=3.5",
"-DCMAKE_POLICY_VERSION_MAXIMUM=3.28",
"-DCMAKE_WARN_DEPRECATED=OFF",
"-DABSL_PROPAGATE_CXX_STD=ON",
"-DTHREADS_PREFER_PTHREAD_FLAG=OFF",
"-DYAZE_BUILD_TESTS=OFF",
"-DYAZE_BUILD_APP=ON",
"-DYAZE_BUILD_LIB=OFF",
"-DYAZE_BUILD_EMU=OFF",
"-DYAZE_BUILD_Z3ED=OFF",
"-DYAZE_ENABLE_ROM_TESTS=OFF",
"-DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF",
"-DYAZE_ENABLE_UI_TESTS=OFF",
"-DYAZE_INSTALL_LIB=OFF",
"-DYAZE_MINIMAL_BUILD=ON"
)
Write-Host "CMake command: cmake $($TestArgs -join ' ') $SourceDir" -ForegroundColor Gray
& cmake @TestArgs $SourceDir
if ($LASTEXITCODE -eq 0) {
Write-Host "✅ CMake configuration test PASSED!" -ForegroundColor Green
Write-Host "The project can be configured successfully." -ForegroundColor Green
# Clean up test build directory
if (Test-Path $TestBuildDir) {
Remove-Item -Recurse -Force $TestBuildDir
Write-Host "Test build directory cleaned up." -ForegroundColor Gray
}
Write-Host "`nYou can now run the full project generation script:" -ForegroundColor Cyan
Write-Host ".\scripts\generate-vs-projects.ps1" -ForegroundColor White
} else {
Write-Host "❌ CMake configuration test FAILED!" -ForegroundColor Red
Write-Host "Please check the error messages above." -ForegroundColor Red
exit 1
}