/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 .):
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
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),configureorconfigure.ac(autotools), or a plainMakefile, and follow the README. - Submodules: an empty
third_party/foodirectory means the submodule was not cloned. Rungit 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 ownCMakeLists.txt. - Case: the name must be
CMakeLists.txt. On Linux,cmakelists.txtis not found.
Sources
Related pages
flags · cmakecmake -S . -B build: set the source and build directoriescmake -S . -B build configures a project from the source directory into a separate build directory; cmake --build build then compiles it. Since CMake 3.13.errors · cmakeCMake Error: No CMAKE_C_COMPILER could be foundCMake fails with No CMAKE_C_COMPILER could be found when project() enables C and no compiler is on PATH. Install gcc, clang or MSVC, or set CMAKE_C_COMPILER.errors · cmakeCMake: Could not find a package configuration file provided by "Foo"find_package(Foo REQUIRED) fails when CMake finds neither FindFoo.cmake nor FooConfig.cmake. Install the dev package, or point CMAKE_PREFIX_PATH at it.