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.cmakeCommon causes
How to fix it
Provide the toolchain file
- Check out the submodule or install the SDK that ships the toolchain.
- 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.
Frequently asked questions
What causes ""Could not find toolchain file""?
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.
How do I fix "Could not find toolchain file"?
Provide the toolchain file
Related guides
CMake "Flow control statements are not properly nested" in CIFix CMake "Flow control statements are not properly nested" in CI - an if/foreach/function block is missing o…
CMake "pkg-config not found" / PKG_CONFIG_EXECUTABLE-NOTFOUND in CIFix CMake "pkg-config not found" in CI - find_package(PkgConfig) failed because the pkg-config tool is not in…
CMake "Could not find toolchain file" in CIFix CMake "Could not find toolchain file" in CI - the path passed to CMAKE_TOOLCHAIN_FILE does not exist on t…