diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 62d090197f..c1bb19bf4f 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -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; diff --git a/Source/cmState.h b/Source/cmState.h index 9a86098124..31ee63aac9 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -231,6 +231,7 @@ public: unsigned int GetCacheMajorVersion() const; unsigned int GetCacheMinorVersion() const; + void SetRoleToProjectForCMakeBuildVsReconfigure(); Role GetRole() const; std::string GetRoleString() const; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 60b2a6f96e..825b637fa7 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -4014,6 +4014,8 @@ int cmake::Build(int jobs, std::string dir, std::vector 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(); diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 547f1d680e..2aa1f0703b 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -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);