【CMake】unable to find a build program corresponding to Ninja 问题解决

【CMAKE】CMake Error: CMake was unable to find a build program corresponding to "Ninja"

CMake 构建错误

CMake 构建时,报了一个错误

c 复制代码
cmake -S. -B. ./build -G"Ninja" ...

完整报错为

c 复制代码
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
-- Configuration incomplete, errors occurred!
See also ".../build/CMakeFiles/CMakeOutput.log"

解决方法

在网上找了很多 有的说 Android 什么的,有的是 Ubuntu 的解决方案,我这里是 Windows 平台开发环境用的 Visual Studio 2019。

解决方法,缺少一个环境变量,添加进去就行了

bash 复制代码
VS2019INSTALLDIR="C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise"

注: 不同的电脑上 Visual Studio 的安装路径或可能不同,根据自己的情况设置。

再次 CMake 运行成功。

相关推荐
Mr_WangAndy5 分钟前
现代C++模板与泛型编程_第4章_remove_all_sequence,integer_sequence,is_union
c++·c++40周年·c++标准库用法
氵文大师10 分钟前
A机通过 python -m http.server 下载B机的文件
linux·开发语言·python·http
封奚泽优22 分钟前
下降算法(Python实现)
开发语言·python·算法
im_AMBER29 分钟前
算法笔记 16 二分搜索算法
c++·笔记·学习·算法
笃行客从不躺平44 分钟前
遇到大SQL怎么处理
java·开发语言·数据库·sql
郝学胜-神的一滴44 分钟前
Python中常见的内置类型
开发语言·python·程序人生·个人开发
g***B7381 小时前
Kotlin协程在Android中的使用
android·开发语言·kotlin
火白学安全1 小时前
《Python红队攻防零基础脚本编写:进阶篇(一)》
开发语言·python·安全·web安全·网络安全·系统安全
6***x5451 小时前
C++在计算机视觉中的图像处理
c++·图像处理·计算机视觉·游戏引擎·logback·milvus
爱码小白1 小时前
PyQt5 QTimer总结
开发语言·qt