Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 75 additions & 5 deletions src/project/build.ps1
Original file line number Diff line number Diff line change
@@ -1,16 +1,86 @@
param (
[switch]
$Package = $false
$Package = $false,
[string]
$QtPath = "C:\Qt\6.9.0\msvc2022_64"
)

if ($IsWindows) {
cmake . -DCMAKE_PREFIX_PATH=C:/Qt/6.9.0/msvc2022_64 -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_FLAGS="/Zc:__cplusplus /permissive-" -B build
cmake --build build --config Release --parallel 32
# Resolve Qt path from parameter, environment variable, or default
if ([string]::IsNullOrEmpty($QtPath)) {
$QtPath = $env:QT_PATH
}
if ([string]::IsNullOrEmpty($QtPath)) {
$QtPath = "C:\Qt\6.9.0\msvc2022_64"
}

# Validate Qt path exists
if (-not (Test-Path $QtPath)) {
Write-Error "Qt path not found at: $QtPath"
Write-Error "Please install Qt 6.9.0 MSVC2022 64-bit from: https://www.qt.io/download"
Write-Error "Or provide the Qt path via -QtPath parameter or QT_PATH environment variable"
exit 1
}

Write-Host "Using Qt at: $QtPath"

# Check if Ninja is installed
if (-not (Get-Command ninja -ErrorAction SilentlyContinue)) {
Write-Error "Ninja build system is not installed. Please install Ninja."
Write-Error "Install via: choco install ninja (or download from https://github.com/ninja-build/ninja/releases)"
exit 1
}

# Check if Visual Studio is installed (including preview versions) for compiler
$vswherePath = "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"
if (-not (Test-Path $vswherePath)) {
Write-Error "vswhere.exe not found at $vswherePath"
Write-Error "Please install Visual Studio 2022 with C++ development tools from: https://visualstudio.microsoft.com/downloads/"
exit 1
}

# Check if Visual Studio is installed (including preview versions) for compiler
$vsPath = & $vswherePath -latest -prerelease -property installationPath 2>$null
if (-not $vsPath) {
Write-Error "Visual Studio is not installed. Please install Visual Studio 2022 with C++ development tools."
Write-Error "Download from: https://visualstudio.microsoft.com/downloads/"
exit 1
}

Write-Host "Using Visual Studio at: $vsPath"

# Use Ninja generator
$generator = "Ninja"
Write-Host "Using CMake generator: $generator"

# Find vcvars64.bat to setup Visual Studio environment
$vcvars = "$vsPath\VC\Auxiliary\Build\vcvars64.bat"
if (-not (Test-Path $vcvars)) {
Write-Error "Visual Studio C++ tools not found. Please install C++ development workload."
exit 1
}

# Setup Visual Studio environment and run CMake with Ninja generator
& cmd /c "`"$vcvars`" && cmake . -G `"$generator`" -DCMAKE_PREFIX_PATH=$QtPath -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_FLAGS=`"/Zc:__cplusplus /permissive-`" -DCMAKE_BUILD_TYPE=Release -B build"
if ($LASTEXITCODE -ne 0) {
Write-Error "CMake configuration failed"
exit $LASTEXITCODE
}

& cmd /c "`"$vcvars`" && cmake --build build --parallel 32"
if ($LASTEXITCODE -ne 0) {
Write-Error "Build failed"
exit $LASTEXITCODE
}

New-Item -ItemType Directory -Path .\build\Release -Force
Copy-Item .\build\SQLiteQueryAnalyzer.exe .\build\Release\SQLiteQueryAnalyzer.exe
& "$QtPath\bin\windeployqt.exe" .\build\Release\SQLiteQueryAnalyzer.exe

Comment thread
christianhelle marked this conversation as resolved.
if ($Package) {
C:\Qt\6.9.0\msvc2022_64\bin\windeployqt.exe .\build\Release\SQLiteQueryAnalyzer.exe
../../deps/innosetup/ISCC.exe setup.iss
}
}
}

if ($IsLinux) {
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./linux/
Expand Down
Loading