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

相关推荐
xiaozi41201 分钟前
Ruey S. Tsay《时间序列分析》Python实现笔记:综合与应用
开发语言·笔记·python·机器学习
西贝爱学习7 分钟前
Visual Studio下载地址,vs2022安装程序
c++
天赐学c语言9 分钟前
12.5 - 二叉树的最近公共祖先 && 构造函数和析构函数可以是虚函数吗
c++·二叉树·虚函数
wearegogog12310 分钟前
DEA模型MATLAB实现(CCR、BCC、超效率)
开发语言·算法·matlab
闻缺陷则喜何志丹17 分钟前
【计算几何】P2785 物理1(phsic1)- 磁通量|普及+
c++·数学·计算几何
郝学胜-神的一滴19 分钟前
Linux定时器编程:深入理解setitimer函数
linux·服务器·开发语言·c++·程序人生
cici1587424 分钟前
基于反向传播算法实现手写数字识别的MATLAB实现
开发语言·算法·matlab
小鱼小鱼.oO27 分钟前
C++ 算法基础知识
c++·算法·哈希算法
昨天那个谁谁1 小时前
ROS2运行时报无法加载create_key等符号错误
c++·python·ros2
不会编程的小寒1 小时前
C and C++ 八股文
c语言·c++·青少年编程