summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-10-27 13:43:20 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-10-27 13:43:39 (GMT)
commitab8801157917c574236ee472e864408405cb83cc (patch)
tree20ebd7ca40df3f65f53f209a2887b835a3f3f14f /Source
parent5eab7ea84bf2549eb14877fd148f54ecfb9e1b75 (diff)
parent7ecbe324b0ef02f63676f8431dbbbe8b4217f64f (diff)
downloadCMake-ab8801157917c574236ee472e864408405cb83cc.zip
CMake-ab8801157917c574236ee472e864408405cb83cc.tar.gz
CMake-ab8801157917c574236ee472e864408405cb83cc.tar.bz2
Merge topic 'cmake-presets-workflow-arguments'
7ecbe324b0 cmake --workflow: add --fresh option 7d9aa0f00c cmake::Workflow: Refactor to use enum class argument 322193afcd cmake --workflow: print usage and exit on unrecognized argument 70aef29427 cmake --workflow: print usage message Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !7825
Diffstat (limited to 'Source')
-rw-r--r--Source/cmake.cxx16
-rw-r--r--Source/cmake.h13
-rw-r--r--Source/cmakemain.cxx32
3 files changed, 49 insertions, 12 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 73b8e88..c068894 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -3742,7 +3742,8 @@ std::function<int()> cmake::BuildWorkflowStep(
}
#endif
-int cmake::Workflow(const std::string& presetName, bool listPresets)
+int cmake::Workflow(const std::string& presetName,
+ WorkflowListPresets listPresets, WorkflowFresh fresh)
{
#ifndef CMAKE_BOOTSTRAP
this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
@@ -3757,7 +3758,7 @@ int cmake::Workflow(const std::string& presetName, bool listPresets)
return 1;
}
- if (listPresets) {
+ if (listPresets == WorkflowListPresets::Yes) {
settingsFile.PrintWorkflowPresetList();
return 0;
}
@@ -3824,10 +3825,13 @@ int cmake::Workflow(const std::string& presetName, bool listPresets)
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 5b5425c..4e7bb54 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -611,7 +611,18 @@ public:
bool Open(const std::string& dir, bool dryRun);
//! run the --workflow option
- int Workflow(const std::string& presetName, bool listPresets);
+ enum class WorkflowListPresets
+ {
+ No,
+ Yes,
+ };
+ 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 928c1ba..43bebc1 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -917,8 +917,11 @@ int do_workflow(int ac, char const* const* av)
std::cerr << "This cmake does not support --workflow\n";
return -1;
#else
+ using WorkflowListPresets = cmake::WorkflowListPresets;
+ using WorkflowFresh = cmake::WorkflowFresh;
std::string presetName;
- bool listPresets = false;
+ auto listPresets = WorkflowListPresets::No;
+ auto fresh = WorkflowFresh::No;
using CommandArgument =
cmCommandLineArgument<bool(std::string const& value)>;
@@ -927,7 +930,15 @@ int do_workflow(int ac, char const* const* av)
CommandArgument{ "--preset", CommandArgument::Values::One,
CommandArgument::setToValue(presetName) },
CommandArgument{ "--list-presets", CommandArgument::Values::Zero,
- CommandArgument::setToTrue(listPresets) }
+ [&listPresets](const std::string&) -> bool {
+ 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;
@@ -949,14 +960,25 @@ int do_workflow(int ac, char const* const* av)
}
if (!(matched && parsed)) {
if (!matched) {
+ presetName.clear();
+ listPresets = WorkflowListPresets::No;
std::cerr << "Unknown argument " << arg << std::endl;
}
break;
}
}
- if (presetName.empty() && !listPresets) {
- std::cerr << "TODO: Usage\n";
+ if (presetName.empty() && listPresets == WorkflowListPresets::No) {
+ /* clang-format off */
+ std::cerr <<
+ "Usage: cmake --workflow [options]\n"
+ "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;
}
@@ -969,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
}