Skip to content

Commit 15465c0

Browse files
committed
Add cmake build script (pwsh)
1 parent a5ca0e5 commit 15465c0

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

build_for_win32.ps1

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
param (
2+
[string]$buildtype = "Release",
3+
[int]$clean = 0 # Before building, delete the build directory entirely
4+
)
5+
6+
function check_command {
7+
param([string]$command)
8+
if ((get-command $command -ea silentlycontinue) -eq $null) {
9+
return 1;
10+
}
11+
return 0;
12+
}
13+
14+
if (check_command("cl") -e 0) {
15+
./vcvars2019.ps1
16+
}
17+
18+
# Check prerequisites
19+
$missing = check_command("cmake")
20+
$missing += check_command("ninja")
21+
$missing += check_command("cl")
22+
23+
if ($missing) {
24+
write-host "Visual Studio 2019 was not found!"
25+
return;
26+
}
27+
28+
$builddir = "$psscriptroot/build/win32/$buildtype"
29+
30+
if ($clean -ne 0) {
31+
write-host "-- Cleaning.."
32+
rm -r -force -ea silentlycontinue $builddir
33+
}
34+
35+
write-host "Building $buildtype to $builddir"
36+
pushd # Store current path
37+
38+
mkdir -ea silentlycontinue $builddir
39+
cd $builddir
40+
41+
cmake ../../../physx -G Ninja -DCMAKE_BUILD_TYPE="$buildtype"
42+
43+
cmake --build . --config $buildtype --target install
44+
45+
popd # Restore current path
46+
47+
exit $LastExitCode

vcvars2019.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pushd "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build"
2+
cmd /c "vcvars64.bat&set" | foreach {
3+
if ($_ -match "=") {
4+
$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
5+
}
6+
}
7+
popd
8+
Write-Host "Visual Studio 2019 Command Prompt variables set." -ForegroundColor Yellow

0 commit comments

Comments
 (0)