correct command line to build and install

I can’t remember where I get it but I’m currently using:

cmake --build . -- install --no-print-directory

To build and install my projects.
Yet I have repeatedly read that the only correct syntax should be:

cmake --build . --target install

But with this syntax, --no-print-directory always rises an error “unknown argument”. By the way, with the former, --no-print-directory is only accepted with the -- install before it.

NB I’m only using --no-print-directory with generator for make.

What is the correct syntax to:

  • only build without printing changes of directory;
  • only install;
  • build and install without printing changes of directory?

regards
A.