Full version:
CMake has several modes in which it can be run, which are triggered by different command-line arguments:
Generate a buildsystem: no special argument, or use -B and maybe -S
Build a project: cmake --build
Install a project: cmake --install
And many others
You can think of cmake --build and cmake --install as subcommands in the same way as e.g. git status and git commit. Just like git status . commit . does not work, neither does cmake --build --install.
See Jakub Zarzewski answer. You have also switched the command and the path.
Besides, as told within the doc, my command line is only available if a target command “install” is generated. It may depend on how the CMakeLists is written. I’m not sure about what are exactly the requirements to have this target.
There seems to be a confusion in usage.
cmake -S … -B build will only perform configuration and generation
cmake --build . <–target install> will build an already generated project (and optionally install the result)