summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-03-21 19:09:23 (GMT)
committerBrad King <brad.king@kitware.com>2022-03-22 13:27:47 (GMT)
commit9f1471739d83c9e61b6700a0c369b7f7bbb19071 (patch)
tree2fb485885eb07f35342bc17485d27946bc819f92 /Source/cmake.cxx
parent7e642a6fa0884cf683a1a50dd5cab93acd1e3950 (diff)
downloadCMake-9f1471739d83c9e61b6700a0c369b7f7bbb19071.zip
CMake-9f1471739d83c9e61b6700a0c369b7f7bbb19071.tar.gz
CMake-9f1471739d83c9e61b6700a0c369b7f7bbb19071.tar.bz2
cmake: Add --fresh option to clear the cache and start from scratch
Simplify the workflow to re-run CMake from scratch as if a build tree were never before processed, regardless of whether it has been. Fixes: #23119
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx12
1 files changed, 12 insertions, 0 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index a602458..5bfc4c8 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -868,6 +868,11 @@ void cmake::SetArgs(const std::vector<std::string>& args)
CommandArgument{ "-B", "No build directory specified for -B",
CommandArgument::Values::One,
CommandArgument::RequiresSeparator::No, BuildArgLambda },
+ CommandArgument{ "--fresh", CommandArgument::Values::Zero,
+ [](std::string const&, cmake* cm) -> bool {
+ cm->FreshCache = true;
+ return true;
+ } },
CommandArgument{ "-P", "-P must be followed by a file name.",
CommandArgument::Values::One,
CommandArgument::RequiresSeparator::No,
@@ -2404,12 +2409,19 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
}
if (this->GetWorkingMode() == NORMAL_MODE) {
+ if (this->FreshCache) {
+ this->DeleteCache(this->GetHomeOutputDirectory());
+ }
// load the cache
if (this->LoadCache() < 0) {
cmSystemTools::Error("Error executing cmake::LoadCache(). Aborting.\n");
return -1;
}
} else {
+ if (this->FreshCache) {
+ cmSystemTools::Error("--fresh allowed only when configuring a project");
+ return -1;
+ }
this->AddCMakePaths();
}