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

There is no need to duplicate these on every cmMakefile.
This commit is contained in:
Stephen Kelly 2015-04-26 17:18:27 +02:00
parent 397b629860
commit 410f39a43e
4 changed files with 19 additions and 21 deletions

View File

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

View File

@ -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

View File

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

View File

@ -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