cmake --job

cmake --help
I cant find --job information.

Here is the command and I want to speed up the build and install.
How can I add some parameter for the command to speed up?

cmake -B build/ -D CMAKE_BUILD_TYPE=Release
cmake --build build/ --config Release
cmake --install build/ --config Release --prefix C:/release/

There is the --parallel (or -j) flag you can use with --build or --install.

2 Likes

The documentation is here: https://cmake.org/cmake/help/latest/manual/cmake.1.html#build-a-project

2 Likes

Can I use both of them (build and install) ?

cmake -B build/ -D CMAKE_BUILD_TYPE=Release
cmake --build build/ --config Release -j12
cmake --install build/ --config Release --prefix C:/release/ -j12

Yes, that is fine.

Does the cmake automatically detect job number and use it without command -j ?

For example,
My PC has 4 job. The command will automatically build with 4 job. So I don’t need to use -j 4

cmake -B build/ -D CMAKE_BUILD_TYPE=Release
cmake --build build/ --config Release
cmake --install build/ --config Release --prefix C:/release/

cmake --help

Build in parallel using the given number of jobs.
                   If <jobs> is omitted the native build tool's
                   default number is used.
                   The CMAKE_BUILD_PARALLEL_LEVEL environment variable
                   specifies a default parallel level when this option
                   is not given

No. It does the default of the generator. For Ninja generators, this is to be parallel (I think ncores + 2 is the heuristic). VS has some weird internal logic, but the rest are not parallel without it being explicit.