我正在使用Visual Studio
打开一个CMake
C++项目。当我在顶部将它设置为x64-Debug
模式并进行编译时,它工作得很好。然而,当我将其更改为x64-Release
时,它突然告诉我:
CMake Error at CMakeLists.txt:5 (project):
Generator
Visual Studio 16 2019
could not find any instance of Visual Studio.
我确实在使用Visual Studio
,为什么CMake
在发布模式下构建时找不到它了?我知道这个代码库以前编译得很好,从那以后我没有对它做任何更改。此外,我尝试修复/重新安装Visual Studio
,但问题仍然存在。我可以验证一些环境变量或CMake
检查的内容吗?
当从CMD
直接运行CMake
以生成Visual Studio
解决方案(cmake -G "Visual Studio 16 2019"
(时,我得到了与上面相同的错误。从x64 Native Tools Command Prompt for VS 2022"
或Developer Command Prompt for VS 2022
运行也没有帮助。
CCD_ 15和CCD_。
>cmake --version
cmake version 3.24.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
事实证明,删除所有Visual Studio
生成的文件/文件夹并设置新的x64-Release
配置解决了这个问题。