# Using two different Visual Studio installations as generator

**URL:** https://discourse.cmake.org/t/using-two-different-visual-studio-installations-as-generator/14465
**Category:** Usage
**Created:** [July 30, 2025, 6:33am UTC](https://discourse.cmake.org/t/using-two-different-visual-studio-installations-as-generator/14465 "2025-07-30T06:33:19Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![bernb](https://discourse.cmake.org/user_avatar/discourse.cmake.org/bernb/32/5629_2.png) [@bernb](https://discourse.cmake.org/u/bernb)
#### Post date: [July 30, 2025, 6:33am UTC](https://discourse.cmake.org/t/using-two-different-visual-studio-installations-as-generator/14465/1 "2025-07-30T06:33:19Z")

</div>

For our software, we want to set a fixed MSVC compiler version (including patch version) when building and want to build two different versions:

```auto
cmake -G "Visual Studio 17 2022" -A x64,version=10.0 -T "v143,version=14.44.35207,cuda=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8"
cmake -G "Visual Studio 17 2022" -A x64,version=10.0 -T "v143,version=14.38.33130,cuda=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8"

```

As it’s not possible to select a specific patch version via the installer, I tried to use two different Visual Studio installations. However, it seems that cmake only consider the latest installation. Is that correct or am I doing something wrong?

---

<div class="post-metadata">

### Author: ![Oodini](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@Oodini](https://discourse.cmake.org/u/Oodini)
#### Post date: [July 30, 2025, 8:21am UTC](https://discourse.cmake.org/t/using-two-different-visual-studio-installations-as-generator/14465/2 "2025-07-30T08:21:06Z")

</div>

It may be related to this problem:

> [@Cannot set toolset when configuring with the Visual Studio 2022 generator.](https://discourse.cmake.org/t/cannot-set-toolset-when-configuring-with-the-visual-studio-2022-generator/10160):
>
> I have installed on my machine Visual Studio 2022 17.9 with the MSVC toolsets 14.36, 14.38 and 14.39. I created with Visual Studio a new “CMake project” and after configuring it with cmake -S . -B build -G "Visual Studio 17 2022" I noticed that CMake is choosing MSVC 14.36; the oldest one. I tried to manually choose the latest toolset by passing -T v143,version=14.39 but every time it fails with No CMAKE\_C/CXX\_COMPILER could be found.. I tried the same while under the Visual Studio developer Po…

---

<div class="post-metadata">

### Author: ![bernb](https://discourse.cmake.org/user_avatar/discourse.cmake.org/bernb/32/5629_2.png) [@bernb](https://discourse.cmake.org/u/bernb)
#### Post date: [July 30, 2025, 10:13am UTC](https://discourse.cmake.org/t/using-two-different-visual-studio-installations-as-generator/14465/3 "2025-07-30T10:13:39Z")

</div>

So cmake normally should be able to find and use msvc versions from all VS installation?  
It does work for me though when I use only one VS installation. That’s unfortunately not an option, because the versions are externally fixed and differ (in their patch version) from what the VS installer provides.

---

<div class="post-metadata">

### Author: ![Oodini](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@Oodini](https://discourse.cmake.org/u/Oodini)
#### Post date: [July 30, 2025, 10:17am UTC](https://discourse.cmake.org/t/using-two-different-visual-studio-installations-as-generator/14465/4 "2025-07-30T10:17:06Z")

</div>

I do have similar troubles:

> [@Can the VS 2019 generator be used if only VS2022 is installed?](https://discourse.cmake.org/t/can-the-vs-2019-generator-be-used-if-only-vs2022-is-installed/6972/4):
>
> For anyone else who finds themselves here, baffled, replace the "-G “Visual Studio 15 2017” or -G “Visual Studio 16 2019” option with -T v142. It will say “Building for: Visual Studio 17 2022” BUT when you open the .sln file it will say “Visual Studio 2019” and the toolset will be set to 2019.
