cmake --build: Convert implementation to internal role

Previously it initialized as `PROJECT` to support reconfiguration with
VS generators, but didn't actually add any commands until needed.
Instead initialize as the `INTERNAL` role and update when adding
commands.
This commit is contained in:
Brad King
2025-10-20 17:42:27 -04:00
parent 0b83750e14
commit ea5d04975e
4 changed files with 9 additions and 1 deletions

View File

@@ -812,6 +812,11 @@ unsigned int cmState::GetCacheMinorVersion() const
return this->CacheManager->GetCacheMinorVersion();
}
void cmState::SetRoleToProjectForCMakeBuildVsReconfigure()
{
this->StateRole = Role::Project;
}
cmState::Role cmState::GetRole() const
{
return this->StateRole;

View File

@@ -231,6 +231,7 @@ public:
unsigned int GetCacheMajorVersion() const;
unsigned int GetCacheMinorVersion() const;
void SetRoleToProjectForCMakeBuildVsReconfigure();
Role GetRole() const;
std::string GetRoleString() const;

View File

@@ -4014,6 +4014,8 @@ int cmake::Build(int jobs, std::string dir, std::vector<std::string> targets,
// Note that the stampList file only exists for VS generators.
if (cmSystemTools::FileExists(stampList) &&
!cmakeCheckStampList(stampList)) {
// Upgrade cmake role from --build to reconfigure the project.
this->State->SetRoleToProjectForCMakeBuildVsReconfigure();
this->AddScriptingCommands();
this->AddProjectCommands();

View File

@@ -680,7 +680,7 @@ int do_build(int ac, char const* const* av)
return 1;
}
cmake cm(cmake::CommandSet::None, cmState::Role::Project);
cmake cm(cmake::CommandSet::None, cmState::Role::Internal);
cmSystemTools::SetMessageCallback(
[&cm](std::string const& msg, cmMessageMetadata const& md) {
cmakemainMessageCallback(msg, md, &cm);