Skip to content

/errors/cmake/does-not-appear-to-contain-cmakelists

CMake Error: The source directory does not appear to contain CMakeLists.txt

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
tool
CMake
exit code
1
versions
CMake 3.x, CMake 4.x
os
any

CMake Error: The source directory "PATH" does not appear to contain CMakeLists.txt. means the directory you passed to cmake (or the current directory with cmake .) has no file named exactly CMakeLists.txt. Most often cmake was run from the build directory with . instead of ... Use the explicit form cmake -S <source-dir> -B <build-dir> and check the file name with ls.

Reproduce it

Using the empty build directory as the source, which is what cmake . does when run inside it (spelled out with -S . -B .):

bash
cat > CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.20)
project(demo LANGUAGES NONE)
EOF
mkdir -p build && cd build
uv run -q --no-project --python 3.13 --with cmake==4.4.4 --with ninja cmake -G Ninja -S . -B .

Output · exit 1

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

Fix: point at the source directory

bash
cat > CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.20)
project(demo LANGUAGES NONE)
EOF
uv run -q --no-project --python 3.13 --with cmake==4.4.4 --with ninja \
  cmake -G Ninja -S . -B build | grep -v 'Build files have been written' | sed 's/ ([0-9.]*s)$//'
ls build | grep -E 'CMakeCache.txt|build.ninja'

Output

-- Configuring done
-- Generating done
CMakeCache.txt
build.ninja

From inside an existing build directory the old form also works: cmake ... With -S and -B (CMake 3.13 and later) the command does not depend on the current directory.

Other causes

  • Not a CMake project: look for meson.build (Meson), configure or configure.ac (autotools), or a plain Makefile, and follow the README.
  • Submodules: an empty third_party/foo directory means the submodule was not cloned. Run git submodule update --init --recursive, or clone with --recursive.
  • add_subdirectory: the same message, with the subdirectory path, appears when add_subdirectory(libs/foo) points to a folder without its own CMakeLists.txt.
  • Case: the name must be CMakeLists.txt. On Linux, cmakelists.txt is not found.

Sources