difference between cmake --build . -- install and cmake --build . followed by cmake --install . ?


I think everything is in the title.

To had a bit of context, so far I was using makefiles generators (linux, nmake, or mingw) then called make install to build and install (or nmake, or mingw32-make). In order to have less boilerplate code in my compilation framework, I would like to take benefit of the cmake cli. Thus I was wondering if xxxmake install was the same thing as cmake --build . -- install.


Yes I have successfully encouraged colleagues and users to do like:

cmake -B build
cmake --build build    # instead of "make"
cmake --install build  # instead of "make install"

Users can set a default number of parallel build threads (handy for make) by setting in ~/.profile or similar on Unix-like systems

# Linux: $(nproc)
# macOS: $(sysctl -n hw.physicalcpu)

Likewise on Windows I set environment variable like


Then you don’t need to use the cmake --build build --parallel option, it’s build in parallel by default like Ninja.