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

相关推荐
Predestination王瀞潞2 小时前
IO操作(Num22)
开发语言·c++
宋恩淇要努力3 小时前
C++继承
开发语言·c++
沿着路走到底4 小时前
python 基础
开发语言·python
沐知全栈开发5 小时前
C# 委托(Delegate)
开发语言
江公望5 小时前
Qt qmlRegisterSingletonType()函数浅谈
c++·qt
任子菲阳6 小时前
学Java第三十四天-----抽象类和抽象方法
java·开发语言
老黄编程6 小时前
ros2 中 CMakeLists.txt 的 ament_package 有什么用?有什么使用约束?必须放置尾部吗?
ros·cmake
csbysj20207 小时前
如何使用 XML Schema
开发语言
R6bandito_7 小时前
STM32中printf的重定向详解
开发语言·经验分享·stm32·单片机·嵌入式硬件·mcu
逆小舟7 小时前
【C/C++】指针
c语言·c++·笔记·学习