cmState: Initialize current directories immediately.

Don't leave this as cmMakefile responsibility.
This commit is contained in:
Stephen Kelly 2015-10-13 21:57:54 +02:00
parent 2c219bafc0
commit 841164cb36
2 changed files with 10 additions and 26 deletions

View File

@ -118,32 +118,6 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
this->AddSourceGroup("Resources", "\\.plist$");
this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
#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()
@ -1756,6 +1730,8 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
newSnapshot.GetDirectory().SetCurrentSource(srcPath);
newSnapshot.GetDirectory().SetCurrentBinary(binPath);
cmSystemTools::MakeDirectory(binPath.c_str());
cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot);
this->GetGlobalGenerator()->AddMakefile(subMf);

View File

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