# CMake Error "could not find any instance of Visual Studio"

**URL:** https://discourse.cmake.org/t/cmake-error-could-not-find-any-instance-of-visual-studio/3164
**Category:** Development
**Tags:** os:windows, gen:vs
**Created:** [April 16, 2021, 4:11pm UTC](https://discourse.cmake.org/t/cmake-error-could-not-find-any-instance-of-visual-studio/3164 "2021-04-16T16:11:36Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ymba9g8j9cjp0wloqf5y/32/1244_2.png) [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)
#### Post date: [April 16, 2021, 4:11pm UTC](https://discourse.cmake.org/t/cmake-error-could-not-find-any-instance-of-visual-studio/3164/1 "2021-04-16T16:11:36Z")

</div>

Had this issue at work. When of my colleagues (let’s call him Bob) messaged me with the following error:

```auto
cmake -S . -B build/ -G "Visual Studio 16 2019"
CMake Error at CMakeLists.txt:11 (project):
  Generator

 

    Visual Studio 16 2019

 

  could not find any instance of Visual Studio.
-- Configuring incomplete, errors occurred!

```

It took us a bit to figure out the solution though.

Bob had already installed VS2019 so we were confused why he was having an issue.

After looking online for a bit I discovered this is a bit of a [common problem](https://duckduckgo.com/?t=ffab&q=could+not+find+any+instance+of+Visual+Studio&ia=web):

- [c++ - CMake problem: could not find any instance of Visual Studio - Stack Overflow](https://stackoverflow.com/questions/60068168/cmake-problem-could-not-find-any-instance-of-visual-studio)
- [could not find any instance of Visual Studio. (solved) · Issue #3472 · ycm-core/YouCompleteMe · GitHub](https://github.com/ycm-core/YouCompleteMe/issues/3472)
- [CMake: Visual Studio 15 2017 could not find any instance of Visual Studio - Stack Overflow](https://stackoverflow.com/questions/51668676/cmake-visual-studio-15-2017-could-not-find-any-instance-of-visual-studio)
- [Solved: Visual Studio 15 2017 could not find any instance of Visual Studio (demo\_squeezenet\_download\_convert\_run.bat - Intel Community](https://community.intel.com/t5/Intel-Distribution-of-OpenVINO/Visual-Studio-15-2017-could-not-find-any-instance-of-Visual/td-p/1180928)

In general the key to solving this problem always seems to be reinstalling/modifying Visual Studio, which ends up repairing the environment so that cmake can find the Visual Studio instance.

What can be done to help users navigate this?  
Is there a bug with Visual Studio installation?

EDIT: We are using cmake 3.19 to reproduce this issue. I don’t believe anything changed in 3.20 regarding this behavior.

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [April 19, 2021, 1:24pm UTC](https://discourse.cmake.org/t/cmake-error-could-not-find-any-instance-of-visual-studio/3164/2 "2021-04-19T13:24:27Z")

</div>

CMake queries the VS Installer through a COM interface to ask for locations of VS instances. It asks only for completed installations, not partial installations, so if the VS Installer requires a reboot or something then it won’t report all installed VS versions.

One might be able to add a second query to ask the VS Installer for _all_ instances, even those not fully installed. We shouldn’t use the latter, but if they are the only instance(s) available, we may be able to generate a better error message. E.g. “found incomplete installation X, check the VS Installer tool”.

---

<div class="post-metadata">

### Author: ![YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ymba9g8j9cjp0wloqf5y/32/1244_2.png) [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)
#### Post date: [April 19, 2021, 9:17pm UTC](https://discourse.cmake.org/t/cmake-error-could-not-find-any-instance-of-visual-studio/3164/3 "2021-04-19T21:17:44Z")

</div>

Should I make an issue on the GitLab then?

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [April 20, 2021, 1:20pm UTC](https://discourse.cmake.org/t/cmake-error-could-not-find-any-instance-of-visual-studio/3164/4 "2021-04-20T13:20:14Z")

</div>

I opened [CMake Issue 22082](https://gitlab.kitware.com/cmake/cmake/-/issues/22082) for this.

---

<div class="post-metadata">

### Author: ![hardik\_bagdariya](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hardik_bagdariya/32/2005_2.png) [@hardik\_bagdariya](https://discourse.cmake.org/u/hardik_bagdariya)
#### Post date: [December 4, 2021, 4:12am UTC](https://discourse.cmake.org/t/cmake-error-could-not-find-any-instance-of-visual-studio/3164/5 "2021-12-04T04:12:01Z")

</div>

CMake Error at CMakeLists.txt:2 (project):  
Generator

```
Visual Studio 16 2019

```

could not find any instance of Visual Studio.

Exception: Unable to generate build files

→ this error proper solution & answer please…
