whn*_*whn 2 c++ cmake visual-c++ visual-studio-2019
与 CMake 类似:Visual Studio 15 2017 找不到 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
Run Code Online (Sandbox Code Playgroud)
到目前为止看起来不错。但当我跑步时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".
Run Code Online (Sandbox Code Playgroud)
我目前正在使用这个版本的cmake:
cmake -version
cmake version 3.20.0-rc2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
Run Code Online (Sandbox Code Playgroud)
所以我应该拥有使用 cmake 的所有最新方法。
我知道我可以手动配置生成器,但是它会随着 cmake 缓存而不断被删除,而且我的印象是 CMake 可以处理多个 Visual Studio 实例,而无需进行此类手动调整,而且我应该能够使用环境变量至少指出每一个,尽管这似乎也不起作用。
如果要生成针对 Visual Studio 2017 平台工具集 (v141) 的目标,但使用 Visual Studio 2019 作为生成器,则可以使用以下 CMake 生成命令
cmake -G "Visual Studio 16 2019" -T v141 ..
Run Code Online (Sandbox Code Playgroud)