Skip to content
Latchkey

CMake "Could not find toolchain file" in CI

CMAKE_TOOLCHAIN_FILE named a file CMake could not locate. A relative path, an uninitialized submodule (vcpkg), or a developer-specific location breaks in CI.

What this error means

Configure aborts at the very start with "Could not find toolchain file", typically pointing at a vcpkg.cmake or a cross-compilation file that is absent.

cmake
CMake Error at CMakeLists.txt:1 (project):
  Could not find toolchain file: /work/vcpkg/scripts/buildsystems/vcpkg.cmake

Common causes

How to fix it

Provide the toolchain file

  1. Check out the submodule or install the SDK that ships the toolchain.
  2. Pass an absolute, existing path to CMAKE_TOOLCHAIN_FILE.
cmake
git submodule update --init vcpkg
cmake -S . -B build \
  -DCMAKE_TOOLCHAIN_FILE="$PWD/vcpkg/scripts/buildsystems/vcpkg.cmake"

How to prevent it

  • Initialize submodules that provide toolchain files and pass absolute paths to CMAKE_TOOLCHAIN_FILE so configuration is location-independent.

Related guides

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