MarkSchofield / PSCMake

A PowerShell module for running CMake builds

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build-CMakeBuild fails if there's only a single preset, and one isn't explicitly specified

MarkSchofield opened this issue · comments

The following code snippet is used to get all of the preset names from the presets json:

    $PresetNames = GetBuildPresetNames $CMakePresetsJson

But if there's only a single preset, then $PresetNames is a string, rather than a collection of stings. And then the code does:

        $Presets = , $PresetNames[0]

hoping to get the first specified preset as a default. The [0] gets the first item from a collection, but the first character in a string. So if there's only a single preset in the CMakePresets.json file - say, 'windows-x64' - the default is chosen to be 'w', which isn't a preset and things fail horribly. If the code were to $Presets = , ($PresetNames[0] | Select-Object -First 1), then things seem to work as expected.

Fixed with #14.