41 lines
1004 B
PowerShell
41 lines
1004 B
PowerShell
param(
|
|
[ValidateSet("Debug", "Release")]
|
|
[string]$Configuration = "Release",
|
|
[string]$BuildDirectory = "build"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
if (-not (Get-Command cmake -ErrorAction SilentlyContinue)) {
|
|
Write-Error "CMake was not found. Install CMake and ensure it is on PATH."
|
|
exit 1
|
|
}
|
|
|
|
$sourceDirectory = Split-Path -Parent $PSScriptRoot
|
|
if ([System.IO.Path]::IsPathRooted($BuildDirectory)) {
|
|
$buildPath = $BuildDirectory
|
|
} else {
|
|
$buildPath = Join-Path $sourceDirectory $BuildDirectory
|
|
}
|
|
|
|
$configureArgs = @(
|
|
"-S", $sourceDirectory,
|
|
"-B", $buildPath,
|
|
"-G", "Ninja",
|
|
"-DCMAKE_CXX_COMPILER=g++",
|
|
"-DCMAKE_BUILD_TYPE=$Configuration"
|
|
)
|
|
|
|
& cmake @configureArgs
|
|
if ($LASTEXITCODE -ne 0) {
|
|
exit $LASTEXITCODE
|
|
}
|
|
|
|
& cmake --build $buildPath --config $Configuration
|
|
if ($LASTEXITCODE -ne 0) {
|
|
exit $LASTEXITCODE
|
|
}
|
|
|
|
$outputPath = Join-Path $buildPath "bin\$($Configuration.ToLowerInvariant())\LumberJack.exe"
|
|
Write-Host "Build complete: $outputPath"
|