cmState: Initialize top level source directories immediately.
Don't leave this as cmMakefile responsibility.
This commit is contained in:
parent
84e0776e77
commit
2c219bafc0
@ -119,10 +119,6 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
|
|||||||
this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
|
this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
this->StateSnapshot.SetDefinition("CMAKE_SOURCE_DIR",
|
|
||||||
this->GetCMakeInstance()->GetHomeDirectory());
|
|
||||||
this->StateSnapshot.SetDefinition("CMAKE_BINARY_DIR",
|
|
||||||
this->GetCMakeInstance()->GetHomeOutputDirectory());
|
|
||||||
{
|
{
|
||||||
const char* dir = this->StateSnapshot.GetDirectory().GetCurrentSource();
|
const char* dir = this->StateSnapshot.GetDirectory().GetCurrentSource();
|
||||||
if (dir)
|
if (dir)
|
||||||
|
@ -306,11 +306,21 @@ cmState::Snapshot cmState::Reset()
|
|||||||
pos->PolicyScope = this->PolicyStack.Root();
|
pos->PolicyScope = this->PolicyStack.Root();
|
||||||
assert(pos->Policies.IsValid());
|
assert(pos->Policies.IsValid());
|
||||||
assert(pos->PolicyRoot.IsValid());
|
assert(pos->PolicyRoot.IsValid());
|
||||||
|
|
||||||
|
{
|
||||||
|
std::string srcDir =
|
||||||
|
cmDefinitions::Get("CMAKE_SOURCE_DIR", pos->Vars, pos->Root);
|
||||||
|
std::string binDir =
|
||||||
|
cmDefinitions::Get("CMAKE_BINARY_DIR", pos->Vars, pos->Root);
|
||||||
this->VarTree.Clear();
|
this->VarTree.Clear();
|
||||||
pos->Vars = this->VarTree.Extend(this->VarTree.Root());
|
pos->Vars = this->VarTree.Extend(this->VarTree.Root());
|
||||||
pos->Parent = this->VarTree.Root();
|
pos->Parent = this->VarTree.Root();
|
||||||
pos->Root = this->VarTree.Root();
|
pos->Root = this->VarTree.Root();
|
||||||
|
|
||||||
|
pos->Vars->Set("CMAKE_SOURCE_DIR", srcDir.c_str());
|
||||||
|
pos->Vars->Set("CMAKE_BINARY_DIR", binDir.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
this->DefineProperty
|
this->DefineProperty
|
||||||
("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY,
|
("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY,
|
||||||
"", "", true);
|
"", "", true);
|
||||||
@ -838,6 +848,7 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot,
|
|||||||
cmState::Snapshot snapshot = cmState::Snapshot(this, pos);
|
cmState::Snapshot snapshot = cmState::Snapshot(this, pos);
|
||||||
originSnapshot.Position->BuildSystemDirectory->Children.push_back(snapshot);
|
originSnapshot.Position->BuildSystemDirectory->Children.push_back(snapshot);
|
||||||
snapshot.InitializeFromParent();
|
snapshot.InitializeFromParent();
|
||||||
|
snapshot.SetDirectoryDefinitions();
|
||||||
return snapshot;
|
return snapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1318,6 +1329,14 @@ void InitializeContentFromParent(T& parentContent,
|
|||||||
contentEndPosition = thisContent.size();
|
contentEndPosition = thisContent.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmState::Snapshot::SetDirectoryDefinitions()
|
||||||
|
{
|
||||||
|
this->SetDefinition("CMAKE_SOURCE_DIR",
|
||||||
|
this->State->GetSourceDirectory());
|
||||||
|
this->SetDefinition("CMAKE_BINARY_DIR",
|
||||||
|
this->State->GetBinaryDirectory());
|
||||||
|
}
|
||||||
|
|
||||||
void cmState::Snapshot::InitializeFromParent()
|
void cmState::Snapshot::InitializeFromParent()
|
||||||
{
|
{
|
||||||
PositionType parent = this->Position->DirectoryParent;
|
PositionType parent = this->Position->DirectoryParent;
|
||||||
|
@ -96,6 +96,8 @@ public:
|
|||||||
const cmState::Snapshot& rhs) const;
|
const cmState::Snapshot& rhs) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void SetDirectoryDefinitions();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend bool operator==(const cmState::Snapshot& lhs,
|
friend bool operator==(const cmState::Snapshot& lhs,
|
||||||
const cmState::Snapshot& rhs);
|
const cmState::Snapshot& rhs);
|
||||||
|
@ -980,6 +980,10 @@ cmGlobalGenerator* cmake::CreateGlobalGenerator(const std::string& gname)
|
|||||||
void cmake::SetHomeDirectory(const std::string& dir)
|
void cmake::SetHomeDirectory(const std::string& dir)
|
||||||
{
|
{
|
||||||
this->State->SetSourceDirectory(dir);
|
this->State->SetSourceDirectory(dir);
|
||||||
|
if (this->CurrentSnapshot.IsValid())
|
||||||
|
{
|
||||||
|
this->CurrentSnapshot.SetDefinition("CMAKE_SOURCE_DIR", dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* cmake::GetHomeDirectory() const
|
const char* cmake::GetHomeDirectory() const
|
||||||
@ -990,6 +994,10 @@ const char* cmake::GetHomeDirectory() const
|
|||||||
void cmake::SetHomeOutputDirectory(const std::string& dir)
|
void cmake::SetHomeOutputDirectory(const std::string& dir)
|
||||||
{
|
{
|
||||||
this->State->SetBinaryDirectory(dir);
|
this->State->SetBinaryDirectory(dir);
|
||||||
|
if (this->CurrentSnapshot.IsValid())
|
||||||
|
{
|
||||||
|
this->CurrentSnapshot.SetDefinition("CMAKE_BINARY_DIR", dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* cmake::GetHomeOutputDirectory() const
|
const char* cmake::GetHomeOutputDirectory() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user