Explorar o código

cmMakefile: Delegate storage of Home dirs to the cmake class.

There is no need to duplicate these on every cmMakefile.
Stephen Kelly %!s(int64=10) %!d(string=hai) anos
pai
achega
410f39a43e
Modificáronse 4 ficheiros con 19 adicións e 21 borrados
  1. 8 13
      Source/cmMakefile.cxx
  2. 0 2
      Source/cmMakefile.h
  3. 5 2
      Source/cmQtAutoGenerators.cxx
  4. 6 4
      Source/cmake.cxx

+ 8 - 13
Source/cmMakefile.cxx

@@ -181,11 +181,11 @@ void cmMakefile::Print() const
   std::cout << " this->StartOutputDirectory; " <<
     this->GetCurrentBinaryDirectory() << std::endl;
   std::cout << " this->HomeOutputDirectory; " <<
-    this->HomeOutputDirectory << std::endl;
+    this->GetHomeOutputDirectory() << std::endl;
   std::cout << " this->cmStartDirectory; " <<
     this->GetCurrentSourceDirectory() << std::endl;
   std::cout << " this->cmHomeDirectory; " <<
-    this->cmHomeDirectory << std::endl;
+    this->GetHomeDirectory() << std::endl;
   std::cout << " this->ProjectName; "
             <<  this->ProjectName << std::endl;
   this->PrintStringVector("this->LinkDirectories", this->LinkDirectories);
@@ -3382,34 +3382,29 @@ cmMakefile::LexicalPushPop::~LexicalPushPop()
 
 const char* cmMakefile::GetHomeDirectory() const
 {
-  return this->cmHomeDirectory.c_str();
+  return this->GetCMakeInstance()->GetHomeDirectory();
 }
 
 void cmMakefile::SetHomeDirectory(const std::string& dir)
 {
-  this->cmHomeDirectory = dir;
-  cmSystemTools::ConvertToUnixSlashes(this->cmHomeDirectory);
-  this->AddDefinition("CMAKE_SOURCE_DIR", this->GetHomeDirectory());
+  this->AddDefinition("CMAKE_SOURCE_DIR", dir.c_str());
   if ( !this->GetDefinition("CMAKE_CURRENT_SOURCE_DIR") )
     {
-    this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", this->GetHomeDirectory());
+    this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", dir.c_str());
     }
 }
 
 const char* cmMakefile::GetHomeOutputDirectory() const
 {
-  return this->HomeOutputDirectory.c_str();
+  return this->GetCMakeInstance()->GetHomeOutputDirectory();
 }
 
 void cmMakefile::SetHomeOutputDirectory(const std::string& dir)
 {
-  this->HomeOutputDirectory = dir;
-  cmSystemTools::ConvertToUnixSlashes(this->HomeOutputDirectory);
-  this->AddDefinition("CMAKE_BINARY_DIR", this->GetHomeOutputDirectory());
+  this->AddDefinition("CMAKE_BINARY_DIR", dir.c_str());
   if ( !this->GetDefinition("CMAKE_CURRENT_BINARY_DIR") )
     {
-    this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
-                        this->GetHomeOutputDirectory());
+    this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", dir.c_str());
     }
 }
 

+ 0 - 2
Source/cmMakefile.h

@@ -878,8 +878,6 @@ protected:
 
   std::string cmStartDirectory;
   std::string StartOutputDirectory;
-  std::string cmHomeDirectory;
-  std::string HomeOutputDirectory;
   std::string cmCurrentListFile;
 
   std::string ProjectName;    // project name

+ 5 - 2
Source/cmQtAutoGenerators.cxx

@@ -1210,10 +1210,11 @@ static cmGlobalGenerator* CreateGlobalGenerator(cmake* cm,
   cmGlobalGenerator* gg = new cmGlobalGenerator();
   gg->SetCMakeInstance(cm);
 
+  cm->SetHomeOutputDirectory(targetDirectory);
+  cm->SetHomeDirectory(targetDirectory);
+
   cmLocalGenerator* lg = gg->CreateLocalGenerator();
-  lg->GetMakefile()->SetHomeOutputDirectory(targetDirectory);
   lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory);
-  lg->GetMakefile()->SetHomeDirectory(targetDirectory);
   lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory);
   gg->SetCurrentLocalGenerator(lg);
 
@@ -1225,6 +1226,8 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
 {
   bool success = true;
   cmake cm;
+  cm.SetHomeOutputDirectory(targetDirectory);
+  cm.SetHomeDirectory(targetDirectory);
   cmGlobalGenerator* gg = CreateGlobalGenerator(&cm, targetDirectory);
   cmMakefile* makefile = gg->GetCurrentLocalGenerator()->GetMakefile();
 

+ 6 - 4
Source/cmake.cxx

@@ -372,13 +372,13 @@ void cmake::ReadListFile(const std::vector<std::string>& args,
   // read in the list file to fill the cache
   if(path)
     {
+    std::string homeDir = this->GetHomeDirectory();
+    std::string homeOutputDir = this->GetHomeOutputDirectory();
+    this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
+    this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory());
     cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator());
-    lg->GetMakefile()->SetHomeOutputDirectory
-      (cmSystemTools::GetCurrentWorkingDirectory());
     lg->GetMakefile()->SetCurrentBinaryDirectory
       (cmSystemTools::GetCurrentWorkingDirectory());
-    lg->GetMakefile()->SetHomeDirectory
-      (cmSystemTools::GetCurrentWorkingDirectory());
     lg->GetMakefile()->SetCurrentSourceDirectory
       (cmSystemTools::GetCurrentWorkingDirectory());
     if (this->GetWorkingMode() != NORMAL_MODE)
@@ -393,6 +393,8 @@ void cmake::ReadListFile(const std::vector<std::string>& args,
       {
       cmSystemTools::Error("Error processing file: ", path);
       }
+    this->SetHomeDirectory(homeDir);
+    this->SetHomeOutputDirectory(homeOutputDir);
     }
 
   // free generic one if generated