Had this issue at work. When of my colleagues (let’s call him Bob) messaged me with the following error:
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:
- c++ - CMake problem: could not find any instance of Visual Studio - Stack Overflow
- could not find any instance of Visual Studio. (solved) · Issue #3472 · ycm-core/YouCompleteMe · GitHub
- CMake: Visual Studio 15 2017 could not find any instance of Visual Studio - Stack Overflow
- Solved: Visual Studio 15 2017 could not find any instance of Visual Studio (demo_squeezenet_download_convert_run.bat - Intel Community
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.