mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-20 21:40:15 +08:00
@@ -1286,6 +1286,12 @@ The options are:
|
|||||||
Lists the available workflow presets. The current working directory must
|
Lists the available workflow presets. The current working directory must
|
||||||
contain CMake preset files.
|
contain CMake preset files.
|
||||||
|
|
||||||
|
.. option:: --fresh
|
||||||
|
|
||||||
|
Perform a fresh configuration of the build tree.
|
||||||
|
This removes any existing ``CMakeCache.txt`` file and associated
|
||||||
|
``CMakeFiles/`` directory, and recreates them from scratch.
|
||||||
|
|
||||||
View Help
|
View Help
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
@@ -3733,7 +3733,7 @@ std::function<int()> cmake::BuildWorkflowStep(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int cmake::Workflow(const std::string& presetName,
|
int cmake::Workflow(const std::string& presetName,
|
||||||
WorkflowListPresets listPresets)
|
WorkflowListPresets listPresets, WorkflowFresh fresh)
|
||||||
{
|
{
|
||||||
#ifndef CMAKE_BOOTSTRAP
|
#ifndef CMAKE_BOOTSTRAP
|
||||||
this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
|
this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
|
||||||
@@ -3815,10 +3815,13 @@ int cmake::Workflow(const std::string& presetName,
|
|||||||
if (!configurePreset) {
|
if (!configurePreset) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
steps.emplace_back(
|
std::vector<std::string> args{ cmSystemTools::GetCMakeCommand(),
|
||||||
stepNumber, "configure"_s, step.PresetName,
|
"--preset", step.PresetName };
|
||||||
this->BuildWorkflowStep({ cmSystemTools::GetCMakeCommand(),
|
if (fresh == WorkflowFresh::Yes) {
|
||||||
"--preset", step.PresetName }));
|
args.emplace_back("--fresh");
|
||||||
|
}
|
||||||
|
steps.emplace_back(stepNumber, "configure"_s, step.PresetName,
|
||||||
|
this->BuildWorkflowStep(args));
|
||||||
} break;
|
} break;
|
||||||
case cmCMakePresetsGraph::WorkflowPreset::WorkflowStep::Type::Build: {
|
case cmCMakePresetsGraph::WorkflowPreset::WorkflowStep::Type::Build: {
|
||||||
auto const* buildPreset = this->FindPresetForWorkflow(
|
auto const* buildPreset = this->FindPresetForWorkflow(
|
||||||
|
@@ -607,7 +607,13 @@ public:
|
|||||||
No,
|
No,
|
||||||
Yes,
|
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 UnwatchUnusedCli(const std::string& var);
|
||||||
void WatchUnusedCli(const std::string& var);
|
void WatchUnusedCli(const std::string& var);
|
||||||
|
@@ -918,8 +918,10 @@ int do_workflow(int ac, char const* const* av)
|
|||||||
return -1;
|
return -1;
|
||||||
#else
|
#else
|
||||||
using WorkflowListPresets = cmake::WorkflowListPresets;
|
using WorkflowListPresets = cmake::WorkflowListPresets;
|
||||||
|
using WorkflowFresh = cmake::WorkflowFresh;
|
||||||
std::string presetName;
|
std::string presetName;
|
||||||
auto listPresets = WorkflowListPresets::No;
|
auto listPresets = WorkflowListPresets::No;
|
||||||
|
auto fresh = WorkflowFresh::No;
|
||||||
|
|
||||||
using CommandArgument =
|
using CommandArgument =
|
||||||
cmCommandLineArgument<bool(std::string const& value)>;
|
cmCommandLineArgument<bool(std::string const& value)>;
|
||||||
@@ -932,6 +934,11 @@ int do_workflow(int ac, char const* const* av)
|
|||||||
listPresets = WorkflowListPresets::Yes;
|
listPresets = WorkflowListPresets::Yes;
|
||||||
return true;
|
return true;
|
||||||
} },
|
} },
|
||||||
|
CommandArgument{ "--fresh", CommandArgument::Values::Zero,
|
||||||
|
[&fresh](const std::string&) -> bool {
|
||||||
|
fresh = WorkflowFresh::Yes;
|
||||||
|
return true;
|
||||||
|
} },
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<std::string> inputArgs;
|
std::vector<std::string> inputArgs;
|
||||||
@@ -968,6 +975,8 @@ int do_workflow(int ac, char const* const* av)
|
|||||||
"Options:\n"
|
"Options:\n"
|
||||||
" --preset <preset> = Workflow preset to execute.\n"
|
" --preset <preset> = Workflow preset to execute.\n"
|
||||||
" --list-presets = List available workflow presets.\n"
|
" --list-presets = List available workflow presets.\n"
|
||||||
|
" --fresh = Configure a fresh build tree, removing any "
|
||||||
|
"existing cache file.\n"
|
||||||
;
|
;
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
return 1;
|
return 1;
|
||||||
@@ -982,7 +991,7 @@ int do_workflow(int ac, char const* const* av)
|
|||||||
cmakemainProgressCallback(msg, prog, &cm);
|
cmakemainProgressCallback(msg, prog, &cm);
|
||||||
});
|
});
|
||||||
|
|
||||||
return cm.Workflow(presetName, listPresets);
|
return cm.Workflow(presetName, listPresets, fresh);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
Tests/RunCMake/CMakePresetsWorkflow/Fresh.cmake
Normal file
4
Tests/RunCMake/CMakePresetsWorkflow/Fresh.cmake
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
option(FRESH_CONFIGURE "" ON)
|
||||||
|
if(NOT FRESH_CONFIGURE)
|
||||||
|
message(FATAL_ERROR "FRESH_CONFIGURE is ${FRESH_CONFIGURE}, should be ON")
|
||||||
|
endif()
|
21
Tests/RunCMake/CMakePresetsWorkflow/Fresh.json.in
Normal file
21
Tests/RunCMake/CMakePresetsWorkflow/Fresh.json.in
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"version": 6,
|
||||||
|
"configurePresets": [
|
||||||
|
{
|
||||||
|
"name": "default",
|
||||||
|
"generator": "@RunCMake_GENERATOR@",
|
||||||
|
"binaryDir": "${sourceDir}/build"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"workflowPresets": [
|
||||||
|
{
|
||||||
|
"name": "Fresh",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"type": "configure",
|
||||||
|
"name": "default"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@@ -10,10 +10,12 @@ function(run_cmake_workflow_presets name)
|
|||||||
set(RunCMake_TEST_BINARY_DIR "${RunCMake_TEST_SOURCE_DIR}/build")
|
set(RunCMake_TEST_BINARY_DIR "${RunCMake_TEST_SOURCE_DIR}/build")
|
||||||
set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}")
|
set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}")
|
||||||
|
|
||||||
set(RunCMake_TEST_NO_CLEAN TRUE)
|
if(NOT RunCMake_TEST_NO_CLEAN)
|
||||||
|
file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}")
|
||||||
|
file(MAKE_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}")
|
set(RunCMake_TEST_NO_CLEAN TRUE)
|
||||||
file(MAKE_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}")
|
|
||||||
|
|
||||||
set(CASE_NAME "${name}")
|
set(CASE_NAME "${name}")
|
||||||
set(CASE_SOURCE_DIR "${RunCMake_SOURCE_DIR}")
|
set(CASE_SOURCE_DIR "${RunCMake_SOURCE_DIR}")
|
||||||
@@ -78,3 +80,10 @@ unset(CMakePresets_ASSETS)
|
|||||||
|
|
||||||
run_cmake_workflow_presets(ListPresets --list-presets)
|
run_cmake_workflow_presets(ListPresets --list-presets)
|
||||||
run_cmake_workflow_presets(InvalidOption -DINVALID_OPTION)
|
run_cmake_workflow_presets(InvalidOption -DINVALID_OPTION)
|
||||||
|
|
||||||
|
set(RunCMake_TEST_NO_CLEAN TRUE)
|
||||||
|
file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/Fresh")
|
||||||
|
file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/Fresh/build")
|
||||||
|
file(WRITE "${RunCMake_BINARY_DIR}/Fresh/build/CMakeCache.txt" "FRESH_CONFIGURE:BOOL=OFF\n")
|
||||||
|
run_cmake_workflow_presets(Fresh --fresh)
|
||||||
|
unset(RunCMake_TEST_NO_CLEAN)
|
||||||
|
Reference in New Issue
Block a user