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

相关推荐
我命由我123456 分钟前
Jetpack Room - Room 查询返回列表无需判空、LIKE 关键字
android·java·开发语言·java-ee·android jetpack·android-studio·android runtime
天恩软件10 分钟前
一分钟学会 C++ 标准模板库智能指针
c++·智能指针
goodluckyaa16 分钟前
Warp shuffle函数
开发语言
j7~18 分钟前
【C++】STL--Vector容器--拆析解剖Vector的实现以及Vector的底层详解(1)
开发语言·c++·vector·迭代器失效·迭代器的使用
森G21 分钟前
76、仿ASIO实现的Linux c++服务器------服务器源码解析----云视频服务项目
c++·qt
xxwl58523 分钟前
Python语言初步认识(1)
开发语言·python·学习
TCW112126 分钟前
AI底层系列:用C++实现线性代数的公式推导与算法设计-6.线性方程组的解集
c++·人工智能·算法
z落落27 分钟前
C# FileStream文件流读取文件
开发语言·c#
砍材农夫30 分钟前
python环境|conda安装和使用(1)
开发语言·后端·python·conda
小欣加油37 分钟前
leetcode3612 用特殊操作处理字符串I
数据结构·c++·算法·leetcode·职场和发展