microsoft / microsoft/vcpkg

Existing VS 2026 CMake project fails generation during detect_compiler

Open
#52,813 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
CMake
Stars
27.5k
Forks
7.7k
Avg merge
2d 19h
Merged PRs (30d)
321

Description

**Describe the bug**

I have a CMake project that built fine for the past 3 months. I'm not certain what changed in my environment other than I usually install the latest VS 2026 Pro updates as they come along. I did also get around to finally uninstalling 2022 and an old community 2026 install since they were not being used any longer.

Now, I can no longer cmake generate and it is failing during the vcpkg compiler detection logic. In the `config-x64-windows-out.log` file (shown below), it says `No CMAKE_C_COMPILER could be found` and suggests setting the `CC` env var to the full path of `cl.exe`, and that does not help.

From the `config-x64-windows-rel-CMakeCache.txt.log` file, one can see the following relevant variables:

```
//Value Computed by CMake
detect_compiler_BINARY_DIR:STATIC=C:/src/vcpkg/buildtrees/detect_compiler/x64-windows-rel

//Vcpkg target triplet (ex. x86-windows)
VCPKG_TARGET_TRIPLET:STRING=x64-windows

//The CMake toolchain file
CMAKE_TOOLCHAIN_FILE:FILEPATH=C:/src/vcpkg/scripts/buildsystems/vcpkg.cmake

//No help, variable specified on the command line.
VCPKG_CHAINLOAD_TOOLCHAIN_FILE:UNINITIALIZED=C:/src/vcpkg/scripts/toolchains/windows.cmake

//The path to the vcpkg manifest directory.
VCPKG_MANIFEST_DIR:PATH=C:/src/vcpkg/scripts/detect_compiler
```

I've wasted most of the day troubleshooting this situation. It appears to also happen with vcpkg included in the VS 2026 installer. However, I have removed it to focus troubleshooting efforts on the one pulled down by `bootstrap-vcpkg.bat`.

Any suggestions on further troubleshooting are welcome.

**Environment**
- OS: Windows 11 Build 26200
- Compiler: Latest VS 2026 updates

**To Reproduce**
Steps to reproduce the behavior:
1. Attempt to re-generate existing project either in VS 2026 IDE or on x64 VS command prompt using `cmake --preset x64-release`. (Both of my presets fail the same way.

**Expected behavior**
I expect this project to generate just fine as it was last week.

**Failure logs**

```
[1/1] "C:/src/vcpkg/downloads/tools/cmake-4.3.3-windows/cmake-4.3.3-windows-x86_64/bin/cmake.exe" -E chdir ".." "C:/src/vcpkg/downloads/tools/cmake-4.3.3-windows/cmake-4.3.3-windows-x86_64/bin/cmake.exe" "C:/src/vcpkg/scripts/detect_compiler" "-G" "Ninja" "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_PREFIX=C:/src/vcpkg/packages/detect_compiler_x64-windows" "-DVCPKG_COMPILER_CACHE_FILE=C:/src/Foo/Bar/build/x64-release/vcpkg_installed/vcpkg/compiler-file-hash-cache.json" "-DCMAKE_MAKE_PROGRAM=C:\Program Files\Microsoft Visual Studio\18\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja\ninja.exe" "-DBUILD_SHARED_LIBS=ON" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=C:/src/vcpkg/scripts/toolchains/windows.cmake" "-DVCPKG_TARGET_TRIPLET=x64-windows" "-DVCPKG_SET_CHARSET_FLAG=ON" "-DVCPKG_PLATFORM_TOOLSET=v145" "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DVCPKG_APPLOCAL_DEPS=OFF" "-DCMAKE_TOOLCHAIN_FILE=C:/src/vcpkg/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON" "-DVCPKG_CXX_FLAGS=" "-DVCPKG_CXX_FLAGS_RELEASE=" "-DVCPKG_CXX_FLAGS_DEBUG=" "-DVCPKG_C_FLAGS=" "-DVCPKG_C_FLAGS_RELEASE=" "-DVCPKG_C_FLAGS_DEBUG=" "-DVCPKG_CRT_LINKAGE=dynamic" "-DVCPKG_LINKER_FLAGS=" "-DVCPKG_LINKER_FLAGS_RELEASE=" "-DVCPKG_LINKER_FLAGS_DEBUG=" "-DVCPKG_TARGET_ARCHITECTURE=x64" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DCMAKE_INSTALL_BINDIR:STRING=bin" "-D_VCPKG_ROOT_DIR=C:/src/vcpkg" "-DZ_VCPKG_ROOT_DIR=C:/src/vcpkg" "-D_VCPKG_INSTALLED_DIR=C:/src/Foo/Bar/build/x64-release/vcpkg_installed" "-DVCPKG_MANIFEST_INSTALL=OFF"
FAILED: [code=1] ../CMakeCache.txt
"C:/src/vcpkg/downloads/tools/cmake-4.3.3-windows/cmake-4.3.3-windows-x86_64/bin/cmake.exe" -E chdir ".." "C:/src/vcpkg/downloads/tools/cmake-4.3.3-windows/cmake-4.3.3-windows-x86_64/bin/cmake.exe" "C:/src/vcpkg/scripts/detect_compiler" "-G" "Ninja" "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_PREFIX=C:/src/vcpkg/packages/detect_compiler_x64-windows" "-DVCPKG_COMPILER_CACHE_FILE=C:/src/Foo/Bar/build/x64-release/vcpkg_installed/vcpkg/compiler-file-hash-cache.json" "-DCMAKE_MAKE_PROGRAM=C:\Program Files\Microsoft Visual Studio\18\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja\ninja.exe" "-DBUILD_SHARED_LIBS=ON" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=C:/src/vcpkg/scripts/toolchains/windows.cmake" "-DVCPKG_TARGET_TRIPLET=x64-windows" "-DVCPKG_SET_CHARSET_FLAG=ON" "-DVCPKG_PLATFORM_TOOLSET=v145" "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DVCPKG_APPLOCAL_DEPS=OFF" "-DCMAKE_TOOLCHAIN_FILE=C:/src/vcpkg/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON" "-DVCPKG_CXX_FLAGS=" "-DVCPKG_CXX_FLAGS_RELEASE=" "-DVCPKG_CXX_FLAGS_DEBUG=" "-DVCPKG_C_FLAGS=" "-DVCPKG_C_FLAGS_RELEASE=" "-DVCPKG_C_FLAGS_DEBUG=" "-DVCPKG_CRT_LINKAGE=dynamic" "-DVCPKG_LINKER_FLAGS=" "-DVCPKG_LINKER_FLAGS_RELEASE=" "-DVCPKG_LINKER_FLAGS_DEBUG=" "-DVCPKG_TARGET_ARCHITECTURE=x64" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DCMAKE_INSTALL_BINDIR:STRING=bin" "-D_VCPKG_ROOT_DIR=C:/src/vcpkg" "-DZ_VCPKG_ROOT_DIR=C:/src/vcpkg" "-D_VCPKG_INSTALLED_DIR=C:/src/Foo/Bar/build/x64-release/vcpkg_installed" "-DVCPKG_MANIFEST_INSTALL=OFF"
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:11 (enable_language):
No CMAKE_C_COMPILER could be found.

Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.

-- Configuring incomplete, errors occurred!
ninja: build stopped: subcommand failed.
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with the reported x64-release CMake preset, then inspect scripts/detect_compiler and scripts/toolchains/windows.cmake alongside the failure at CMakeLists.txt:11. Compare the compiler environment and generated cache values with a working configuration; done means compiler detection and project generation complete successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.