forked from RealDeuce/OpenDoors
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-msvc.ps1
More file actions
54 lines (41 loc) · 1.37 KB
/
Copy pathbuild-msvc.ps1
File metadata and controls
54 lines (41 loc) · 1.37 KB
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
[CmdletBinding()]
param(
[ValidateSet('x86', 'x64')]
[string]$Architecture = 'x64',
[ValidateSet('Debug', 'Release')]
[string]$Configuration = 'Release',
[switch]$WarningsAsErrors,
[switch]$Clean
)
$ErrorActionPreference = 'Stop'
if ($env:OS -ne 'Windows_NT') {
throw 'build-msvc.ps1 must be run on Windows.'
}
if (-not (Get-Command cmake -ErrorAction SilentlyContinue)) {
throw 'CMake was not found on PATH.'
}
$sourceDirectory = $PSScriptRoot
$buildDirectory = Join-Path $sourceDirectory "build\msvc\$Architecture"
$cmakePlatform = if ($Architecture -eq 'x86') { 'Win32' } else { 'x64' }
if ($Clean -and (Test-Path -LiteralPath $buildDirectory)) {
Remove-Item -LiteralPath $buildDirectory -Recurse -Force
}
$configureArguments = @(
'-S', $sourceDirectory,
'-B', $buildDirectory,
'-A', $cmakePlatform
)
if ($WarningsAsErrors) {
$configureArguments += '-DOPENDOORS_WARNINGS_AS_ERRORS=ON'
}
Write-Host "Configuring OpenDoors for $Architecture..."
& cmake @configureArguments
if ($LASTEXITCODE -ne 0) {
throw 'CMake configuration failed. Ensure a compatible Visual Studio generator and MSVC toolchain are installed.'
}
Write-Host "Building OpenDoors ($Configuration)..."
& cmake --build $buildDirectory --config $Configuration
if ($LASTEXITCODE -ne 0) {
throw 'CMake build failed.'
}
Write-Host "Build complete: $buildDirectory"