Add -B<path-to-binary-tree> to set the path to directory where CMake will store generated files. There must be no spaces between -B and <path-to-binary-tree>. Always must be used with -H option.

Path to this directory will be saved in CMAKE_BINARY_DIR variable.


Starting with CMake 3.13, -B is an officially supported flag, can handle spaces correctly and can be used independently of the -S or -H options.

cmake -B _builds .

See also