Skip to content
Latchkey

CMake "Could not find a package configuration file provided by X" in CI

A find_package() in CONFIG mode looked for X-config.cmake or XConfig.cmake and found none in any searched prefix. The package is not installed or not on CMAKE_PREFIX_PATH.

What this error means

Configure aborts naming the package and listing the directories CMake searched for its config file, on a CI image where the dependency is absent.

cmake
CMake Error at CMakeLists.txt:6 (find_package):
  Could not find a package configuration file provided by "fmt" with any of
  the following names:
    fmtConfig.cmake
    fmt-config.cmake

Common causes

How to fix it

Install the package and point CMake at it

  1. Install the dependency (and its -dev package) that ships the config file.
  2. Pass CMAKE_PREFIX_PATH for packages in a custom prefix.
cmake
apt-get install -y libfmt-dev
cmake -S . -B build -DCMAKE_PREFIX_PATH=/opt/fmt

How to prevent it

  • Provision all find_package dependencies in the runner image and pass CMAKE_PREFIX_PATH for any in a non-standard prefix.

Frequently asked questions

What causes ""Could not find a package configuration file""?
Configure aborts naming the package and listing the directories CMake searched for its config file, on a CI image where the dependency is absent.
How do I fix "Could not find a package configuration file"?
Install the package and point CMake at it

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card