summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2022-10-25 11:13:35 -0400
committerKyle Edwards <kyle.edwards@kitware.com>2022-10-26 12:01:25 -0400
commit7ecbe324b0ef02f63676f8431dbbbe8b4217f64f (patch)
treeccf713a19358c59cf7cb3a370079b2c5b1764e52 /Source
parent7d9aa0f00cd9f7c2ed3d0c710090e9901c4430e9 (diff)
downloadcmake-7ecbe324b0ef02f63676f8431dbbbe8b4217f64f.tar.gz
cmake --workflow: add --fresh option
Fixes: #24073
Diffstat (limited to 'Source')
-rw-r--r--Source/cmake.cxx13
-rw-r--r--Source/cmake.h8
-rw-r--r--Source/cmakemain.cxx11
3 files changed, 25 insertions, 7 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 169bf9e6e7..013a87b510 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -3733,7 +3733,7 @@ std::function<int()> cmake::BuildWorkflowStep(
#endif
int cmake::Workflow(const std::string& presetName,
- WorkflowListPresets listPresets)
+ WorkflowListPresets listPresets, WorkflowFresh fresh)
{
#ifndef CMAKE_BOOTSTRAP
this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
@@ -3815,10 +3815,13 @@ int cmake::Workflow(const std::string& presetName,
if (!configurePreset) {
return 1;
}
- steps.emplace_back(
- stepNumber, "configure"_s, step.PresetName,
- this->BuildWorkflowStep({ cmSystemTools::GetCMakeCommand(),
- "--preset", step.PresetName }));
+ std::vector<std::string> args{ cmSystemTools::GetCMakeCommand(),
+ "--preset", step.PresetName };
+ if (fresh == WorkflowFresh::Yes) {
+ args.emplace_back("--fresh");
+ }
+ steps.emplace_back(stepNumber, "configure"_s, step.PresetName,
+ this->BuildWorkflowStep(args));
} break;
case cmCMakePresetsGraph::WorkflowPreset::WorkflowStep::Type::Build: {
auto const* buildPreset = this->FindPresetForWorkflow(
diff --git a/Source/cmake.h b/Source/cmake.h
index b3b9f19de9..3183577131 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -607,7 +607,13 @@ public:
No,
Yes,
};
- int Workflow(const std::string& presetName, WorkflowListPresets listPresets);
+ enum class WorkflowFresh
+ {
+ No,
+ Yes,
+ };
+ int Workflow(const std::string& presetName, WorkflowListPresets listPresets,
+ WorkflowFresh fresh);
void UnwatchUnusedCli(const std::string& var);
void WatchUnusedCli(const std::string& var);
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index a6938bc37b..723932eb96 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -918,8 +918,10 @@ int do_workflow(int ac, char const* const* av)
return -1;
#else
using WorkflowListPresets = cmake::WorkflowListPresets;
+ using WorkflowFresh = cmake::WorkflowFresh;
std::string presetName;
auto listPresets = WorkflowListPresets::No;
+ auto fresh = WorkflowFresh::No;
using CommandArgument =
cmCommandLineArgument<bool(std::string const& value)>;
@@ -932,6 +934,11 @@ int do_workflow(int ac, char const* const* av)
listPresets = WorkflowListPresets::Yes;
return true;
} },
+ CommandArgument{ "--fresh", CommandArgument::Values::Zero,
+ [&fresh](const std::string&) -> bool {
+ fresh = WorkflowFresh::Yes;
+ return true;
+ } },
};
std::vector<std::string> inputArgs;
@@ -968,6 +975,8 @@ int do_workflow(int ac, char const* const* av)
"Options:\n"
" --preset <preset> = Workflow preset to execute.\n"
" --list-presets = List available workflow presets.\n"
+ " --fresh = Configure a fresh build tree, removing any "
+ "existing cache file.\n"
;
/* clang-format on */
return 1;
@@ -982,7 +991,7 @@ int do_workflow(int ac, char const* const* av)
cmakemainProgressCallback(msg, prog, &cm);
});
- return cm.Workflow(presetName, listPresets);
+ return cm.Workflow(presetName, listPresets, fresh);
#endif
}