Skip to content
Latchkey

CMake "By not providing FindX.cmake ... could not find a package configuration file" in CI

find_package looks for a FindX.cmake module, then an XConfig.cmake config. When neither exists it prints "By not providing FindX.cmake ... could not find a package configuration file provided by X" and lists the prefixes it searched.

What this error means

Configuration fails at a find_package line, telling you to set X_DIR or add the install prefix to CMAKE_PREFIX_PATH because no config file was located.

CMake
CMake Error at CMakeLists.txt:5 (find_package):
  By not providing "Findfmt.cmake" in CMAKE_MODULE_PATH this project has asked
  CMake to find a package configuration file provided by "fmt", but CMake did
  not find one.

  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 or add its prefix

  1. Install the development package that ships XConfig.cmake.
  2. If it is in a custom prefix, add that prefix to CMAKE_PREFIX_PATH.
Terminal
apt-get install -y libfmt-dev
# or point at a custom install
cmake -S . -B build -DCMAKE_PREFIX_PATH=/opt/fmt

Set X_DIR to the config directory

When the config exists in a known place, point find_package straight at it with the X_DIR variable.

Terminal
cmake -S . -B build -Dfmt_DIR=/opt/fmt/lib/cmake/fmt

How to prevent it

  • Install dependencies that ship CMake configs and set CMAKE_PREFIX_PATH for custom prefixes so find_package resolves the same way on every runner.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →