cmake: Add option to reset build tree and start from scratch
Sometimes users want to re-run CMake from scratch as if the build tree were never before processed. Currently this can be done either by removing the entire build directory, or by removing CMakeCache.txt
and CMakeFiles/
from the top-level directory of the build tree.
This use case could be simplified if CMake had an option to say "pretend this is the first invocation on this build tree". Internally CMake would then wipe out CMakeCache.txt
and CMakeFiles/
if they exist, and then start configuring from scratch.
For example:
$ cmake --fresh -S src -B build
would treat the build
directory as a fresh build tree. If it has a CMakeCache.txt
and/or CMakeFiles/
, they will be removed first. Either way, the configure step then runs from scratch in the build tree.
Edited by Brad King