Skip to content
Latchkey

CMake "source directory does not appear to contain CMakeLists.txt" in CI

CMake looked for CMakeLists.txt in the directory it was given and did not find one. The -S path is wrong, or the project lives in a subdirectory.

What this error means

Configure aborts saying the source directory does not contain CMakeLists.txt, often because CI runs cmake from the repo root while the project is nested.

cmake
CMake Error: The source directory "/work" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

Common causes

How to fix it

Point -S at the project root

  1. Pass the directory that actually contains CMakeLists.txt to -S.
  2. Verify the file is present in the checkout.
cmake
cmake -S ./src -B build   # directory holding CMakeLists.txt

How to prevent it

  • Use explicit -S and -B paths in CI and confirm the working directory matches the project layout.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →