Browse Source

cmState: Initialize current directories immediately.

Don't leave this as cmMakefile responsibility.
Stephen Kelly 10 năm trước cách đây
mục cha
commit
841164cb36
2 tập tin đã thay đổi với 10 bổ sung26 xóa
  1. 2 26
      Source/cmMakefile.cxx
  2. 8 0
      Source/cmState.cxx

+ 2 - 26
Source/cmMakefile.cxx

@@ -118,32 +118,6 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
   this->AddSourceGroup("Resources", "\\.plist$");
   this->AddSourceGroup("Resources", "\\.plist$");
   this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
   this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
 #endif
 #endif
-
-  {
-  const char* dir = this->StateSnapshot.GetDirectory().GetCurrentSource();
-  if (dir)
-    {
-    this->StateSnapshot.SetDefinition("CMAKE_CURRENT_SOURCE_DIR", dir);
-    }
-  else
-    {
-    this->StateSnapshot.SetDefinition("CMAKE_CURRENT_SOURCE_DIR",
-                        this->GetCMakeInstance()->GetHomeDirectory());
-    }
-  }
-  {
-  const char* dir = this->StateSnapshot.GetDirectory().GetCurrentBinary();
-  if (dir)
-    {
-    cmSystemTools::MakeDirectory(dir);
-    this->StateSnapshot.SetDefinition("CMAKE_CURRENT_BINARY_DIR", dir);
-    }
-  else
-    {
-    this->StateSnapshot.SetDefinition("CMAKE_CURRENT_BINARY_DIR",
-                        this->GetCMakeInstance()->GetHomeOutputDirectory());
-    }
-  }
 }
 }
 
 
 cmMakefile::~cmMakefile()
 cmMakefile::~cmMakefile()
@@ -1756,6 +1730,8 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
   newSnapshot.GetDirectory().SetCurrentSource(srcPath);
   newSnapshot.GetDirectory().SetCurrentSource(srcPath);
   newSnapshot.GetDirectory().SetCurrentBinary(binPath);
   newSnapshot.GetDirectory().SetCurrentBinary(binPath);
 
 
+  cmSystemTools::MakeDirectory(binPath.c_str());
+
   cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot);
   cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot);
   this->GetGlobalGenerator()->AddMakefile(subMf);
   this->GetGlobalGenerator()->AddMakefile(subMf);
 
 

+ 8 - 0
Source/cmState.cxx

@@ -1020,6 +1020,8 @@ void cmState::Directory::SetCurrentSource(std::string const& dir)
       loc,
       loc,
       this->DirectoryState->CurrentSourceDirectoryComponents);
       this->DirectoryState->CurrentSourceDirectoryComponents);
   this->ComputeRelativePathTopSource();
   this->ComputeRelativePathTopSource();
+
+  this->Snapshot_.SetDefinition("CMAKE_CURRENT_SOURCE_DIR", loc.c_str());
 }
 }
 
 
 const char* cmState::Directory::GetCurrentBinary() const
 const char* cmState::Directory::GetCurrentBinary() const
@@ -1038,6 +1040,8 @@ void cmState::Directory::SetCurrentBinary(std::string const& dir)
       loc,
       loc,
       this->DirectoryState->CurrentBinaryDirectoryComponents);
       this->DirectoryState->CurrentBinaryDirectoryComponents);
   this->ComputeRelativePathTopBinary();
   this->ComputeRelativePathTopBinary();
+
+  this->Snapshot_.SetDefinition("CMAKE_CURRENT_BINARY_DIR", loc.c_str());
 }
 }
 
 
 void cmState::Snapshot::SetListFile(const std::string& listfile)
 void cmState::Snapshot::SetListFile(const std::string& listfile)
@@ -1333,8 +1337,12 @@ void cmState::Snapshot::SetDirectoryDefinitions()
 {
 {
   this->SetDefinition("CMAKE_SOURCE_DIR",
   this->SetDefinition("CMAKE_SOURCE_DIR",
                       this->State->GetSourceDirectory());
                       this->State->GetSourceDirectory());
+  this->SetDefinition("CMAKE_CURRENT_SOURCE_DIR",
+                      this->State->GetSourceDirectory());
   this->SetDefinition("CMAKE_BINARY_DIR",
   this->SetDefinition("CMAKE_BINARY_DIR",
                       this->State->GetBinaryDirectory());
                       this->State->GetBinaryDirectory());
+  this->SetDefinition("CMAKE_CURRENT_BINARY_DIR",
+                      this->State->GetBinaryDirectory());
 }
 }
 
 
 void cmState::Snapshot::InitializeFromParent()
 void cmState::Snapshot::InitializeFromParent()