I have a source directory with a folder called \"phantom-dir/\" where I put all generated files I don\'t need. I want to put all generated files by CMake inside this phantom
You could make use of the undocumented CMake options -H
and -B
to avoid leaving your source dir. -H
specifies the path to the main CMakeLists.txt file, and -B
specifies the path to your desired build directory.
cmake -H. -Bphantom-dir
Note that these are undocumented and so I suppose could change at any time the Kitware guys feel like.
To build your project without leaving your source dir, you can make use of the (official) option --build This is a cross-platform way to invoke your chosen build tool, and you can pass whatever flags you want to this tool. e.g.
cmake --build phantom-dir -- -j3