windows下配置Ninja
描述:
mac上的android工程,改为在windows下继续开发。报错:
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.
分析:
这是因为在windows系统上,缺少Ninja工具。
Ninja 是Google的一名程序员推出的注重速度的构建工具,一般在Unix/Linux上的程序通过make/makefile来构建编译,而Ninja通过将编译任务并行组织,大大提高了构建速度。
解决:
安装配置Ninja的windows版。普遍有两种方式,一种直接安装exe,一种编译安装,两种皆可。
ninja资源:
https://ninja-build.org/
https://github.com/ninja-build/ninja
下载安装包:
https://github.com/ninja-build/ninja/releases
我们的目标地址是windows,所以选择ninja-win.zip下载。
安装:
以exe方式为例,
- 放入一个合适的目录,比如我的路径是 D:\userGreenSoft\ninja\Ninja.exe。
- 将其放入系统Path变量
在命令行窗口输入:
ninja --help
如果有输出帮助信息,说明安装配置成功。
$ ninja --help
usage: ninja [options] [targets...]if targets are unspecified, builds the 'default' target (see manual).options:--version print ninja version ("1.10.0")-v, --verbose show all command lines while building-C DIR change to DIR before doing anything else-f FILE specify input build file [default=build.ninja]-j N run N jobs in parallel (0 means infinity) [default=6 on this system]-k N keep going until N jobs fail (0 means infinity) [default=1]-l N do not start new jobs if the load average is greater than N-n dry run (don't run commands but act like they succeeded)-d MODE enable debugging (use '-d list' to list modes)-t TOOL run a subtool (use '-t list' to list subtools)terminates toplevel options; further flags are passed to the tool-w FLAG adjust warnings (use '-w list' to list warnings)
需要注意的是,Android Studio编辑器需要重启后,Ninja配置才会生效。
关闭后再次打开,进行编译。不出意外就会通过编译了。