blob: a5c01e57bd86131108bea0c88eae7c0acb27ddce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
$originalLocation = Get-Location
$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $scriptPath
. $scriptPath\_entry.ps1
$generator = ""
$arch = "x64"
$vsPaths = @(
"C:\Program Files\Microsoft Visual Studio\2022\Community",
"C:\Program Files\Microsoft Visual Studio\2022\Professional",
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise",
"C:\Program Files\Microsoft Visual Studio\2022\BuildTools",
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community",
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional",
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise",
"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools",
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community",
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional",
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise",
"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
)
foreach ($path in $vsPaths) {
if (Test-Path $path) {
if ($path -match "2022") {
$generator = "Visual Studio 17 2022"
} elseif ($path -match "2019") {
$generator = "Visual Studio 16 2019"
} elseif ($path -match "2017") {
$generator = "Visual Studio 15 2017"
}
break
}
}
if ([string]::IsNullOrEmpty($generator)) {
if (Get-Command ninja -ErrorAction SilentlyContinue) {
$generator = "Ninja"
}
elseif (Get-Command nmake -ErrorAction SilentlyContinue) {
$generator = "NMake Makefiles"
}
elseif (Get-Command mingw32-make -ErrorAction SilentlyContinue) {
$generator = "MinGW Makefiles"
}
else {
Write-Host "No suitable generator found. Please install Visual Studio or another build system." -ForegroundColor Red
exit 1
}
}
if (!(Test-Path -Path "..\build")) {
New-Item -ItemType Directory -Path "..\build" | Out-Null
}
Set-Location "..\build"
if ($generator -match "Visual Studio") {
if ($generator -match "Visual Studio 15 2017") {
cmake .. -G "$generator" -A $arch
} else {
cmake .. -G "$generator" -A $arch
}
} else {
cmake .. -G "$generator"
}
if ($LASTEXITCODE -ne 0) {
Write-Host "CMake configuration failed!" -ForegroundColor Red
Set-Location $originalLocation
exit 1
}
if ($generator -match "Visual Studio") {
cmake --build . --config Release
} else {
cmake --build .
}
if ($LASTEXITCODE -ne 0) {
Write-Host "Build failed!" -ForegroundColor Red
Set-Location $originalLocation
exit 1
}
Set-Location $originalLocation
|