# Can the VS 2019 generator be used if only VS2022 is installed?

**URL:** https://discourse.cmake.org/t/can-the-vs-2019-generator-be-used-if-only-vs2022-is-installed/6972
**Category:** Usage
**Tags:** os:windows, gen:vs
**Created:** [November 28, 2022, 4:10pm UTC](https://discourse.cmake.org/t/can-the-vs-2019-generator-be-used-if-only-vs2022-is-installed/6972 "2022-11-28T16:10:58Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Garrick](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@Garrick](https://discourse.cmake.org/u/Garrick)
#### Post date: [November 28, 2022, 4:10pm UTC](https://discourse.cmake.org/t/can-the-vs-2019-generator-be-used-if-only-vs2022-is-installed/6972/1 "2022-11-28T16:10:59Z")

</div>

If Visual Studio 2022 is installed, including the older Toolset V142, and NO VS2019 is installed, can the ‘Visual Studio 16 2019 Generator’ be used, to create a solution targeting the old toolset?

Our large application is currently stuck on CMake 3.15.x, however our team is migrating to Visual Studio 2022. Until now we’ve kept the buildscripts locked to VS Toolset 142 and haven’t had a problem. Now we have our first developer whose installed VS2022 with no Visual Studio 2019 present and gets an error:

```auto
CMake Error at CMakeLists.txt:89 (project):
  Generator

    Visual Studio 16 2019

  could not find any instance of Visual Studio.

```

Before firing CMake, our build scripts run these two tools:

```auto
%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe
%FoundVsInstallDir%\VC\Auxiliary\Build\vcvarsall.bat

```

After tweaking the build-scripts, I realized even on my machine ‘vswhere.exe’ is now detecting a VS 2022 Enterprise on D:\ first, but CMake is using VS2019 in the default location. I can’t see how CMake is selecting that.

If we can’t upgrade CMake at this time, is having VS2019 installed simply for the GENERATOR a forced requirement?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [November 30, 2022, 7:47pm UTC](https://discourse.cmake.org/t/can-the-vs-2019-generator-be-used-if-only-vs2022-is-installed/6972/2 "2022-11-30T19:47:44Z")

</div>

Yes. Note that VS2022 does have components for VS2019 toolchains last I checked, so you can use the VS2022 generator with the known-good toolchain.

---

<div class="post-metadata">

### Author: ![Garrick](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@Garrick](https://discourse.cmake.org/u/Garrick)
#### Post date: [December 2, 2022, 9:17pm UTC](https://discourse.cmake.org/t/can-the-vs-2019-generator-be-used-if-only-vs2022-is-installed/6972/3 "2022-12-02T21:17:06Z")

</div>

Thanks for confirming it should be possible. I will investigate further and post back if the solution isn’t specific to our stuff. I’ve recreated the error message on a 2nd machine, but it’s still not fully configured yet either.

---

<div class="post-metadata">

### Author: ![blackbirdsr72](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/3bc359/32.png) [@blackbirdsr72](https://discourse.cmake.org/u/blackbirdsr72)
#### Post date: [July 28, 2025, 6:22pm UTC](https://discourse.cmake.org/t/can-the-vs-2019-generator-be-used-if-only-vs2022-is-installed/6972/4 "2025-07-28T18:22:37Z")

</div>

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.

---

<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:32am UTC](https://discourse.cmake.org/t/can-the-vs-2019-generator-be-used-if-only-vs2022-is-installed/6972/5 "2025-07-30T08:32:45Z")

</div>

Yet, I’m facing right now troubles with `ExternalProject_Add()`, with **CMake 3.31.6**.  
I have Visual Studio 2022, and with Visual Studio Installer, installed “MSVC v141 - VS 2017”.

In the call to `ExternalProject_Add()`, I added:

- `CMAKE_GENERATOR_TOOLSET v141`
- `CMAKE_GENERATOR_TOOLSET "v141"`
- `-DCMAKE_GENERATOR_TOOLSET:STRING=v141`

but in the cache, I always get:

```auto
//Name of generator toolset.
CMAKE_GENERATOR_TOOLSET:INTERNAL=

```

I also added to the call to the CMake command the switch `-T v141`, but no more success.

---

<div class="post-metadata">

### Author: ![blackbirdsr72](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/3bc359/32.png) [@blackbirdsr72](https://discourse.cmake.org/u/blackbirdsr72)
#### Post date: [July 30, 2025, 12:38pm UTC](https://discourse.cmake.org/t/can-the-vs-2019-generator-be-used-if-only-vs2022-is-installed/6972/6 "2025-07-30T12:38:04Z")

</div>

Does the same thing happen with CMake 4.x?  
Are there any errors or warnings produced when CMake is run?

---

<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, 3:28pm UTC](https://discourse.cmake.org/t/can-the-vs-2019-generator-be-used-if-only-vs2022-is-installed/6972/7 "2025-07-30T15:28:26Z")

</div>

I didn’t switched yet to CMake 4.x.
