-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.ps1
47 lines (42 loc) · 1.64 KB
/
build.ps1
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
#!/usr/bin/env pwsh
$number_of_build_workers=8
if (Get-Command "cl.exe" -ErrorAction SilentlyContinue) {
$vstype = "Professional"
if (Test-Path "C:\Program Files (x86)\Microsoft Visual Studio\2019\${vstype}\Common7\Tools") {
}
else {
$vstype = "Enterprise"
if (Test-Path "C:\Program Files (x86)\Microsoft Visual Studio\2019\${vstype}\Common7\Tools") {
}
else {
$vstype = "Community"
}
}
Write-Host "Found VS 2019 ${vstype}" -ForegroundColor Yellow
Push-Location "C:\Program Files (x86)\Microsoft Visual Studio\2019\${vstype}\Common7\Tools"
cmd /c "VsDevCmd.bat -arch=x64 & set" |
ForEach-Object {
if ($_ -match "=") {
$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
}
}
Pop-Location
Write-Host "Visual Studio 2019 ${vstype} Command Prompt variables set.`n" -ForegroundColor Yellow
}
else {
Write-Host "No Compiler found" -ForegroundColor Red
}
# DEBUG
Remove-Item .\build_win_debug -Force -Recurse -ErrorAction SilentlyContinue
New-Item -Path .\build_win_debug -ItemType directory -Force
Set-Location build_win_debug
cmake -G "Visual Studio 16 2019" -T "host=x64" -A "x64" "-DCMAKE_BUILD_TYPE=Debug" ..
cmake --build . --config Debug --parallel ${number_of_build_workers} --target install
Set-Location ..
# RELEASE
Remove-Item .\build_win_release -Force -Recurse -ErrorAction SilentlyContinue
New-Item -Path .\build_win_release -ItemType directory -Force
Set-Location build_win_release
cmake -G "Visual Studio 16 2019" -T "host=x64" -A "x64" "-DCMAKE_BUILD_TYPE=Release" ..
cmake --build . --config Release --parallel ${number_of_build_workers} --target install
Set-Location ..