Browse Source

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.
Brad King 1 month ago
parent
commit
ea5d04975e
4 changed files with 9 additions and 1 deletions
  1. 5 0
      Source/cmState.cxx
  2. 1 0
      Source/cmState.h
  3. 2 0
      Source/cmake.cxx
  4. 1 1
      Source/cmakemain.cxx

+ 5 - 0
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;

+ 1 - 0
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;
 

+ 2 - 0
Source/cmake.cxx

@@ -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();
 

+ 1 - 1
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);