[CmdletBinding()]
param(
    [string]$Preset = "windows-msvc-default",
    [switch]$NoApp
)

$ErrorActionPreference = "Stop"
$started = Get-Date
$argsList = @("--preset", $Preset)
if ($NoApp) {
    $argsList += "-DPP_BUILD_APP=OFF"
}

& cmake @argsList
$exitCode = $LASTEXITCODE
$elapsed = [int]((Get-Date) - $started).TotalMilliseconds

[ordered]@{
    command = "configure"
    preset = $Preset
    exitCode = $exitCode
    elapsedMs = $elapsed
} | ConvertTo-Json -Compress

exit $exitCode
