Issue
I'm using Visual Studio
to open a CMake
C++ project. When I set it to x64-Debug
mode at the top and compile, it works fine. However, when I change it to x64-Release
, it suddenly tells me:
CMake Error at CMakeLists.txt:5 (project):
Generator
Visual Studio 16 2019
could not find any instance of Visual Studio.
I'm literally using Visual Studio
, why does CMake
not find it anymore when building in release mode? I know that this code base compiled perfectly fine before and I didn't make any changes to it since then. Also, I tried to repair/reinstall Visual Studio
but the issue persists. Can I verify some environment variables or whatever CMake
checks?
When running CMake
from CMD
directly to generate a Visual Studio
solution (cmake -G "Visual Studio 16 2019"
), I get the same error as above. Running from x64 Native Tools Command Prompt for VS 2022"
or Developer Command Prompt for VS 2022
does not help either.
Desktop development with C++
and C++ CMake tools for Windows
are both installed.
>cmake --version
cmake version 3.24.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
Solution
It turns out that deleting all Visual Studio
generated files/folders and setting up a new x64-Release
configuration solved the problem.
Answered By - BullyWiiPlaza Answer Checked By - Cary Denson (WPSolving Admin)