Help with presets: invalid preset

Once again, my CMake lack-of-knowledge is laid bare. I decided today to play around with presets and whipped up this file:

{
  "version": 2,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 20,
    "patch": 3
  },
  "configurePresets": [
    {
      "name": "Release",
      "displayName": "Release Config",
      "description": "Release build using GNU Make generator",
      "generator": "Unix Makefiles",
      "binaryDir": "${sourceDir}/build-Release",
      "cacheVariables": {
        "BASEDIR": "$env{BASEDIR}/Darwin",
        "CMAKE_BUILD_TYPE": "Release",
        "CMAKE_INSTALL_PREFIX": "${sourceDir}/install-Release"
      }
    }
  ],
  "buildPresets": [
    {
      "name": "Release",
      "configurePreset": "Release",
      "targets": "install"
    }
  ]
}

I’m mainly piggybacking off of other examples I saw out there.

What I’m aiming for is for this to be equivalent to:

mkdir build-Release
cd build-Release
cmake .. -DBASEDIR=$BASEDIR/Darwin -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install-Release

However, I must have got something wrong:

❯ cmake --version
cmake version 3.20.3

CMake suite maintained and supported by Kitware (kitware.com/cmake).
❯ cmake -S .  --list-presets
CMake Error: Could not read presets from /Users/mathomp4/Models/MAPL-Try/MAPL: Invalid preset

I’m sure it’s blindingly obvious, but I’m just stumped!

Looks like there’s been a mistake on our end. The documentation claims that target can be either a string or a list of strings, but it only seems to accept a list of strings. I’ll open a bug on GitLab.

See https://gitlab.kitware.com/cmake/cmake/-/issues/22272.

Ahhh. Gotcha. this:

"targets": ["install"]

seems happier:

❯ cmake -S .  --list-presets
Available configure presets:

  "Release" - Release Config

New oddity @kyle.edwards . So I fiddled some more and did this:

  "buildPresets": [
    {
      "name": "Release",
      "configurePreset": "Release",
      "jobs": 4,
      "targets": ["install"]
    }
  ]

Adding the jobs field/key/thing. I guess my hope is that:

cmake --preset=Release
cmake --build --preset=Release

where the last one would be like:

cmake --build --preset=Release -j4

but it doesn’t seem to be doing things in parallel. Just ye olde -j 1. If I add on the -j 4 then it does seem to do 4 jobs at once.

Please open a bug on GitLab for that.

Done. See https://gitlab.kitware.com/cmake/cmake/-/issues/22273