Skip to content

Commit 6884df9

Browse files
Fix hardcoded Qt paths by introducing -QtPath argument to build.ps1
1 parent 558a6ac commit 6884df9

1 file changed

Lines changed: 23 additions & 10 deletions

File tree

src/project/build.ps1

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
param (
22
[switch]
3-
$Package = $false
3+
$Package = $false,
4+
[string]
5+
$QtPath = "C:\Qt\6.9.0\msvc2022_64"
46
)
57

68
if ($IsWindows) {
9+
# Resolve Qt path from parameter, environment variable, or default
10+
if ([string]::IsNullOrEmpty($QtPath)) {
11+
$QtPath = $env:QT_PATH
12+
}
13+
if ([string]::IsNullOrEmpty($QtPath)) {
14+
$QtPath = "C:\Qt\6.9.0\msvc2022_64"
15+
}
16+
17+
# Validate Qt path exists
18+
if (-not (Test-Path $QtPath)) {
19+
Write-Error "Qt path not found at: $QtPath"
20+
Write-Error "Please install Qt 6.9.0 MSVC2022 64-bit from: https://www.qt.io/download"
21+
Write-Error "Or provide the Qt path via -QtPath parameter or QT_PATH environment variable"
22+
exit 1
23+
}
24+
25+
Write-Host "Using Qt at: $QtPath"
26+
727
# Check if Ninja is installed
828
if (-not (Get-Command ninja -ErrorAction SilentlyContinue)) {
929
Write-Error "Ninja build system is not installed. Please install Ninja."
@@ -33,13 +53,6 @@ if ($IsWindows) {
3353
$generator = "Ninja"
3454
Write-Host "Using CMake generator: $generator"
3555

36-
# Check if Qt is installed
37-
if (-not (Test-Path "C:\Qt\6.9.0\msvc2022_64")) {
38-
Write-Error "Qt 6.9.0 MSVC2022 64-bit is not installed at C:\Qt\6.9.0\msvc2022_64"
39-
Write-Error "Please install Qt 6.9.0 for MSVC 2022 64-bit from: https://www.qt.io/download"
40-
exit 1
41-
}
42-
4356
# Find vcvars64.bat to setup Visual Studio environment
4457
$vcvars = "$vsPath\VC\Auxiliary\Build\vcvars64.bat"
4558
if (-not (Test-Path $vcvars)) {
@@ -48,7 +61,7 @@ if ($IsWindows) {
4861
}
4962

5063
# Setup Visual Studio environment and run CMake with Ninja generator
51-
& cmd /c "`"$vcvars`" && cmake . -G `"$generator`" -DCMAKE_PREFIX_PATH=C:\Qt\6.9.0\msvc2022_64 -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_FLAGS=`"/Zc:__cplusplus /permissive-`" -DCMAKE_BUILD_TYPE=Release -B build"
64+
& 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"
5265
if ($LASTEXITCODE -ne 0) {
5366
Write-Error "CMake configuration failed"
5467
exit $LASTEXITCODE
@@ -62,7 +75,7 @@ if ($IsWindows) {
6275

6376
New-Item -ItemType Directory -Path .\build\Release -Force
6477
Copy-Item .\build\SQLiteQueryAnalyzer.exe .\build\Release\SQLiteQueryAnalyzer.exe
65-
C:\Qt\6.9.0\msvc2022_64\bin\windeployqt.exe .\build\Release\SQLiteQueryAnalyzer.exe
78+
& "$QtPath\bin\windeployqt.exe" .\build\Release\SQLiteQueryAnalyzer.exe
6679

6780
if ($Package) {
6881
../../deps/innosetup/ISCC.exe setup.iss

0 commit comments

Comments
 (0)