【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 天前
【矩阵找最大小所在位置】2022-11-13
c语言·c++·经验分享·笔记·算法·矩阵
小柯J桑_1 天前
C++之特殊类设计
java·开发语言·c++
QiZhang | UESTC1 天前
JAVA算法练习题day11
java·开发语言·python·算法·hot100
bigdata-rookie1 天前
Java 反射
java·开发语言
能工智人小辰1 天前
Java8 Swing实现计算器
开发语言
SccTsAxR1 天前
[C语言]常见排序算法①
c语言·开发语言·经验分享·笔记·其他·排序算法
bikong71 天前
Qt/C++,windows多进程demo
c++·windows·qt
努力学习的小廉1 天前
我爱学算法之—— 位运算(上)
c++·算法
青草地溪水旁1 天前
设计模式(C++)详解—原型模式(1)
c++·设计模式·原型模式
怀旧,1 天前
【C++】20. unordered_set和unordered_map
开发语言·c++