Difference between ninja and cmake

Viewed 3507

Follow the commands:

First I do cmake -G Ninja ..

then

cmake --build . -j10

or

ninja -j10

My question is, what is the best command or the difference between them?

1 Answers

When you run cmake -G Ninja.. it essentially means that you are using a build system namely Ninja. For better understanding this visual depiction will further clarify. Furthermore, the Ninja in cmake -G Ninja.. will generate Ninja build files.

Regarding your question what is the difference between cmake --build . -j10 and ninja -j10?

Apparently there is no difference in your case as you have already run cmake -G Ninja .. previously. Both cmake --build . -j10 and ninja -j10 are fine in your case.

To further clarify, the -j means "number of jobs". And to put it more precisely, it is -jN. Where N explicitly sets "number of jobs" to run in parallel. This means your build will use 10 threads as you have -j10

Related