CMake Error: Could not find a package configuration file provided by "Foo" (requested version 1.2)
find_package(Foo) could not locate the library's CMake config (FooConfig.cmake or FindFoo.cmake), so the library is not installed or CMake is not told where it is.
Could not find a package configuration file provided byBy not providing "FindFoo.cmake" in CMAKE_MODULE_PATHAdd the installation prefix of "Foo" to CMAKE_PREFIX_PATHCMake Error at CMakeLists.txt: find_packageCould NOT find OpenSSL (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR) Meaning
CMake searches standard prefixes plus CMAKE_PREFIX_PATH, <Package>_DIR and the system package registry. Install the library's development package, or point CMake at the install prefix. For libraries that provide only pkg-config files, use find_package(PkgConfig).
Common causes
- Development package not installed (
libfoo-dev,foo-devel, Homebrew formula) - Library installed in a custom prefix CMake does not search
- Wrong package name or case (
OpenCVvsopencv) - Version requested is higher than the installed one
- Package ships only a pkg-config file, no CMake config
⚡ Quick fix
- Install the development package or build the library and
cmake --installit - Pass the prefix:
cmake -DCMAKE_PREFIX_PATH=/opt/foo ..or-DFoo_DIR=/opt/foo/lib/cmake/Foo - Check the exact package name in the library docs
Detailed fix by platform
CMake
cmake -S . -B build -DCMAKE_PREFIX_PATH=/opt/foo- Debug the search:
cmake --debug-find -S . -B build(3.17+) - For pkg-config libraries:
find_package(PkgConfig REQUIRED)+pkg_check_modules(FOO REQUIRED foo)
Linux
apt search libfoo-dev/dnf search foo-develto find the package;find / -name "FooConfig.cmake" 2>/dev/nullto locate an existing install
Code examples
Telling CMake where the package is
cmake_minimum_required(VERSION 3.16)
project(app)
find_package(Foo 1.2 REQUIRED) # looks for FooConfig.cmake
add_executable(app main.cpp)
target_link_libraries(app PRIVATE Foo::Foo)
# configure with:
# cmake -S . -B build -DCMAKE_PREFIX_PATH=/opt/fooHow to diagnose
- Name — Exact package name in the docs?
- Install — Is FooConfig.cmake on disk?
- Prefix — Is its prefix in CMAKE_PREFIX_PATH?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in C/C++
- terminate called after throwing an instance of C++: terminate called after throwing an instance of 'std::out_of_range' — what(): vector::_M_range_check
- double free or corruption C/C++: free(): double free detected / double free or corruption (out) — Aborted (core dumped)
- expected ';' before C/C++: error: expected ';' before 'x' — missing semicolon
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 15 Oct 2026