/errors/cmake/could-not-find-package-configuration-file
CMake: Could not find a package configuration file provided by "Foo"
- tool
- CMake
- exit code
- 1
- versions
- CMake 3.x, CMake 4.x
- os
- any
find_package(Foo REQUIRED) looks first for a find module, FindFoo.cmake, in CMAKE_MODULE_PATH and CMake's own modules, then for a config file installed by the library itself (FooConfig.cmake, foo-config.cmake, and in CMake 4 also Foo.cps) under the install prefixes it searches. When it finds neither, configuration stops with Could not find a package configuration file provided by "Foo" and lists the names it tried.
Reproduce it
CMake 4.4 from the official cmake Python wheel, with the Ninja generator and no compilers (LANGUAGES NONE):
cat > CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.20)
project(demo LANGUAGES NONE)
find_package(Foo REQUIRED)
EOF
uv run -q --no-project --python 3.13 --with cmake==4.4.4 --with ninja cmake -G Ninja -S . -B buildOutput · exit 1
CMake Error at CMakeLists.txt:3 (find_package):
By not providing "FindFoo.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Foo", but
CMake did not find one.
Could not find a package configuration file provided by "Foo" with any of
the following names:
Foo.cps
foo.cps
FooConfig.cmake
foo-config.cmake
Add the installation prefix of "Foo" to CMAKE_PREFIX_PATH or set "Foo_DIR"
to a directory containing one of the above files. If "Foo" provides a
separate development package or SDK, be sure it has been installed.
-- Configuring incomplete, errors occurred!Fix: install it, or tell CMake where it is
sudo apt install libfoo-dev # Debian/Ubuntu: the -dev package ships FooConfig.cmake
cmake -S . -B build -DCMAKE_PREFIX_PATH=/opt/foo # searched as /opt/foo/lib/cmake/Foo/ and similar
cmake -S . -B build -DFoo_DIR=/opt/foo/lib/cmake/Foo # the directory that contains FooConfig.cmakeFind where a config file lives: find / -name 'FooConfig.cmake' -o -name 'foo-config.cmake' 2>/dev/null.
Optional dependencies
Without REQUIRED, CMake only sets Foo_FOUND to false and continues:
find_package(Foo)
if(Foo_FOUND)
target_link_libraries(app PRIVATE Foo::Foo)
endif()