开发环境:Window10+VS2019+CMake3.26.0
错误提示:
“CMAKE_C_COMPILER-NOTFOUND” was not found.Please setCMAKE_C_COMPILER to a valid compiler path or name.
“CMAKE_CXX_COMPILER-NOTFOUND” was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
以上提示大致意思就是未找到CMake C与C++的编译器,需要设置编译器目录或者名称。
解决办法:
- 检查系统环境变量内VS2019是否配置完善
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VCC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDEC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build
WindowsSoftware Development Kit (SDK) for Windows 10是否安装(Debugger必须安装)
检查VS C++模块是否安装齐全
若以上都完善,那可能是CMake寻找编译器失败了,可以使用以下命令手动指定编译器位置
cmake -DCMAKE_CXX_COMPILER="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe"
注:以上14.29.30133为我安装的MSVC版本,此目录请根据自己的电脑进行调整