类似于CMake: Visual Studio 15 2017 could not find any instance of Visual Studio但就我而言,我的 MSVC 生成器的主要安装版本正在运行。 2017 年的发电机似乎对我不起作用。这是我的安装设置:
我的理解是这应该有效,我应该有合适的工具。
当我运行 cmake -G "Visual Studio 16 2019"../
我明白了
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
-- The C compiler identification is MSVC 19.28.29337.0
-- The CXX compiler identification is MSVC 19.28.29337.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/.../build
到目前为止看起来不错。但是当我运行 cmake -G "Visual Studio 15 2017"../
我明白了
CMake Error at CMakeLists.txt:2 (project):
Generator
Visual Studio 15 2017
could not find any instance of Visual Studio.
-- Configuring incomplete, errors occurred!
See also "C:/.../build/CMakeFiles/CMakeOutput.log".
我目前使用的是这个版本的 cmake:
cmake -version
cmake version 3.20.0-rc2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
所以我应该掌握了使用 cmake 的所有最新方法。
我知道我可以手动配置生成器,但它会保留在 cmake 缓存中并不断被删除,我的印象是 CMake 可以处理多个 visual studio 实例而无需进行此类手动调整,而且我应该能够至少使用环境变量指向每个环境变量,尽管这似乎也不起作用。
最佳答案
如果您想要生成针对 Visual Studio 2017 平台工具集 (v141),但使用 Visual Studio 2019 作为生成器,您将使用以下 CMake 生成命令
cmake -G "Visual Studio 16 2019" -T v141 ..
关于c++ - CMake 找不到生成的 Visual Studio 15 2017 实例,但可以与 Visual Studio 16 2019 一起正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66376188/