Visual Studio 在 x64-Debug 模式下使用 CMake 编译,但在 x64-Release 模式下编译"could not find any instance of Visual



我正在使用Visual Studio打开一个CMakeC++项目。当我在顶部将它设置为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配置解决了这个问题。

相关内容

最新更新