# How do I set the compiler version for Visual Studio generator with cmake presets

**URL:** https://discourse.cmake.org/t/how-do-i-set-the-compiler-version-for-visual-studio-generator-with-cmake-presets/8779
**Category:** Usage
**Created:** [August 20, 2023, 12:02am UTC](https://discourse.cmake.org/t/how-do-i-set-the-compiler-version-for-visual-studio-generator-with-cmake-presets/8779 "2023-08-20T00:02:15Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Orhun\_Birsoy](https://discourse.cmake.org/user_avatar/discourse.cmake.org/orhun_birsoy/32/2798_2.png) [@Orhun\_Birsoy](https://discourse.cmake.org/u/Orhun_Birsoy)
#### Post date: [August 20, 2023, 12:02am UTC](https://discourse.cmake.org/t/how-do-i-set-the-compiler-version-for-visual-studio-generator-with-cmake-presets/8779/1 "2023-08-20T00:02:15Z")

</div>

I have “14.36-17.6” and “14.37-17.7” build tools installed with VS 17.7.1.

I would like to specify the compiler version to be used in a `CMakePresets.json` file.

My `CMakePresets.json` file looks like the following:

```json
{
  "version": 6,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 27,
    "patch": 0
  },
  "configurePresets": [
    {
      "name": "windows",
      "generator": "Visual Studio 17 2022",
      "binaryDir": "${sourceDir}/out/build/${presetName}",
      "architecture": {
        "value": "ARM64"
      },
      "toolset": {
        "value": "host=x64,version=14.36"
      },
      "cacheVariables": {
        "CMAKE_VERBOSE_MAKEFILE": "ON",
        "CMAKE_CONFIGURATION_TYPES": "Debug;RelWithDebInfo",
        "CMAKE_SYSTEM_VERSION": "10.0"
      }
    }
  ]
}

```

When I run `cmake --fresh --preset windows`, I get the following output.

```plaintext
Preset CMake variables:

  CMAKE_CONFIGURATION_TYPES="Debug;RelWithDebInfo"
  CMAKE_SYSTEM_VERSION="10.0"
  CMAKE_VERBOSE_MAKEFILE="ON"

-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:2 (project):
  No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:2 (project):
  No CMAKE_CXX_COMPILER could be found.

-- Configuring incomplete, errors occurred!

```

If I don’t specify the `version=14.36` (or `version=14.37`) in the `toolset` block, the “latest” compiler `14.37-17.7` (i.e. `19.37.32822.0`) is chosen and both configure and build works.

The issue seems to be that the generated `CompilerIdC(XX).vcxproj` is not correct. Basically, the imported `Microsoft.VCToolsVersion.14.36.17.6.props` doesn’t seem to be designed to be used the way cmake is using it, as it refers to another props file that doesn’t exist.

As far as I can tell, cmake just needs to provide the `<VCToolsVersion>14.36.32532</VCToolsVersion>` and not import the props file in the generated vcxproj file.

Is this a bug in cmake VS generator or is there another way I can specify any compiler version that might be installed with VS?

Thanks.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [August 20, 2023, 11:31pm UTC](https://discourse.cmake.org/t/how-do-i-set-the-compiler-version-for-visual-studio-generator-with-cmake-presets/8779/2 "2023-08-20T23:31:55Z")

</div>

I think you’re getting bitten by a change made in Visual Studio starting with the 14.36 toolset. See the following issue for details:

[https://gitlab.kitware.com/cmake/cmake/-/issues/25192](https://gitlab.kitware.com/cmake/cmake/-/issues/25192)
