CMake "cmake –list-presets" results in "source directory does not exist"

CMake "cmake –list-presets" results in "source directory does not exist"

Problem Description:

I’m trying to get a CMake project to build in a Gitlab runner.

running cmake version 3.18.4

I’m following this documentation from microsoft

I’m running this command in my source directory where a CMakePresets.json file is present:

cmake --list-presets

I’m expecting a list of presets to show up in the command line like this:

Available configure presets:

  "x64-debug"   - x64 Debug
  "x64-release" - x64 Release
  "x86-debug"   - x86 Debug
  "x86-release" - x86 Release

Instead I get the following:
Command line output
the "/–list-presets" folder does indeed not exist nor should it.

I have tried manually specifying the source directory as seen in this question/issue
changing my command into:

cmake -S . --list-presets

But it yields the same result.

Solution – 1

I run this in a gitlab runner for CI/CD.
I run the following command to install cmake:

apt-get install cmake

this installs cmake 3.18.4 which does not support presets.
Visual studio which I use for developing run 3.24 which does support and thus uses presets.

I fixed this by running the following script which I got here

    - apt-get update
    - apt-get install gpg wget
    - wget -O - 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
    - echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] focal main' | tee /etc/apt/sources.list.d/kitware.list >/dev/null
    - apt-get update

After which you can get the latest cmake by running:

apt-get install cmake
Rate this post
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.