【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 运行成功。

相关推荐
努力实干1 小时前
面向对象设计原则——C++
开发语言·c++·数码相机
NetX行者3 小时前
四语言 Hello World 背后:编译模型与运行时对比
开发语言
Pin_Qing4 小时前
账单没超,请求先被拒了
大数据·开发语言·人工智能
2601_962885724 小时前
如何用 Python 计算 VaR 和 CVaR(在险价值)?
开发语言·python
郝亚军4 小时前
manifest 中 `sha256` 与 `signValue` 的作用
java·开发语言·数据结构
syagain_zsx4 小时前
jsoncpp 使用指南:编译链接、Json::Value 取值与高频坑
c++·json·库·http格式
譕痕4 小时前
stripe 实例
java·开发语言·stripe·checksession
墨子夕5 小时前
设计模式——Java × Python 双语言精讲 · 23 个经典模式 + 现代演进(前言篇)
java·开发语言·设计模式
_菜鸟果果5 小时前
高德地图 JS API 2.0 在国产 Linux/ARM 电脑上渲染失败 的排查与解决
linux·开发语言·javascript
布莱克6055 小时前
理解 = delete 与 = default:两种赋值语义的差异
c++