cmState: Store the Current directories.
This commit is contained in:
parent
3a041c5949
commit
46f6a5f458
@ -1647,33 +1647,27 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
|
|||||||
|
|
||||||
void cmMakefile::SetCurrentSourceDirectory(const std::string& dir)
|
void cmMakefile::SetCurrentSourceDirectory(const std::string& dir)
|
||||||
{
|
{
|
||||||
this->cmStartDirectory = dir;
|
this->StateSnapshot.SetCurrentSourceDirectory(dir);
|
||||||
cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory);
|
|
||||||
this->cmStartDirectory =
|
|
||||||
cmSystemTools::CollapseFullPath(this->cmStartDirectory);
|
|
||||||
this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
|
this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
|
||||||
this->cmStartDirectory.c_str());
|
this->StateSnapshot.GetCurrentSourceDirectory());
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* cmMakefile::GetCurrentSourceDirectory() const
|
const char* cmMakefile::GetCurrentSourceDirectory() const
|
||||||
{
|
{
|
||||||
return this->cmStartDirectory.c_str();
|
return this->StateSnapshot.GetCurrentSourceDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmMakefile::SetCurrentBinaryDirectory(const std::string& dir)
|
void cmMakefile::SetCurrentBinaryDirectory(const std::string& dir)
|
||||||
{
|
{
|
||||||
this->StartOutputDirectory = dir;
|
this->StateSnapshot.SetCurrentBinaryDirectory(dir);
|
||||||
cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory);
|
const char* binDir = this->StateSnapshot.GetCurrentBinaryDirectory();
|
||||||
this->StartOutputDirectory =
|
cmSystemTools::MakeDirectory(binDir);
|
||||||
cmSystemTools::CollapseFullPath(this->StartOutputDirectory);
|
this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", binDir);
|
||||||
cmSystemTools::MakeDirectory(this->StartOutputDirectory.c_str());
|
|
||||||
this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
|
|
||||||
this->StartOutputDirectory.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* cmMakefile::GetCurrentBinaryDirectory() const
|
const char* cmMakefile::GetCurrentBinaryDirectory() const
|
||||||
{
|
{
|
||||||
return this->StartOutputDirectory.c_str();
|
return this->StateSnapshot.GetCurrentBinaryDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -858,8 +858,6 @@ protected:
|
|||||||
// Check for a an unused variable
|
// Check for a an unused variable
|
||||||
void CheckForUnused(const char* reason, const std::string& name) const;
|
void CheckForUnused(const char* reason, const std::string& name) const;
|
||||||
|
|
||||||
std::string cmStartDirectory;
|
|
||||||
std::string StartOutputDirectory;
|
|
||||||
std::string cmCurrentListFile;
|
std::string cmCurrentListFile;
|
||||||
|
|
||||||
std::string ProjectName; // project name
|
std::string ProjectName; // project name
|
||||||
|
@ -472,6 +472,8 @@ cmState::Snapshot cmState::CreateSnapshot(Snapshot originSnapshot)
|
|||||||
{
|
{
|
||||||
PositionType pos = this->ParentPositions.size();
|
PositionType pos = this->ParentPositions.size();
|
||||||
this->ParentPositions.push_back(originSnapshot.Position);
|
this->ParentPositions.push_back(originSnapshot.Position);
|
||||||
|
this->Locations.resize(this->Locations.size() + 1);
|
||||||
|
this->OutputLocations.resize(this->OutputLocations.size() + 1);
|
||||||
return cmState::Snapshot(this, pos);
|
return cmState::Snapshot(this, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,3 +483,34 @@ cmState::Snapshot::Snapshot(cmState* state, PositionType position)
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* cmState::Snapshot::GetCurrentSourceDirectory() const
|
||||||
|
{
|
||||||
|
return this->State->Locations[this->Position].c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmState::Snapshot::SetCurrentSourceDirectory(std::string const& dir)
|
||||||
|
{
|
||||||
|
assert(this->State->Locations.size() > this->Position);
|
||||||
|
this->State->Locations[this->Position] = dir;
|
||||||
|
cmSystemTools::ConvertToUnixSlashes(
|
||||||
|
this->State->Locations[this->Position]);
|
||||||
|
this->State->Locations[this->Position] =
|
||||||
|
cmSystemTools::CollapseFullPath(this->State->Locations[this->Position]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* cmState::Snapshot::GetCurrentBinaryDirectory() const
|
||||||
|
{
|
||||||
|
return this->State->OutputLocations[this->Position].c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmState::Snapshot::SetCurrentBinaryDirectory(std::string const& dir)
|
||||||
|
{
|
||||||
|
assert(this->State->OutputLocations.size() > this->Position);
|
||||||
|
this->State->OutputLocations[this->Position] = dir;
|
||||||
|
cmSystemTools::ConvertToUnixSlashes(
|
||||||
|
this->State->OutputLocations[this->Position]);
|
||||||
|
this->State->OutputLocations[this->Position] =
|
||||||
|
cmSystemTools::CollapseFullPath(
|
||||||
|
this->State->OutputLocations[this->Position]);
|
||||||
|
}
|
||||||
|
@ -31,6 +31,11 @@ public:
|
|||||||
public:
|
public:
|
||||||
Snapshot(cmState* state = 0, PositionType position = 0);
|
Snapshot(cmState* state = 0, PositionType position = 0);
|
||||||
|
|
||||||
|
const char* GetCurrentSourceDirectory() const;
|
||||||
|
void SetCurrentSourceDirectory(std::string const& dir);
|
||||||
|
const char* GetCurrentBinaryDirectory() const;
|
||||||
|
void SetCurrentBinaryDirectory(std::string const& dir);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class cmState;
|
friend class cmState;
|
||||||
cmState* State;
|
cmState* State;
|
||||||
@ -120,6 +125,8 @@ private:
|
|||||||
std::map<std::string, cmCommand*> Commands;
|
std::map<std::string, cmCommand*> Commands;
|
||||||
cmPropertyMap GlobalProperties;
|
cmPropertyMap GlobalProperties;
|
||||||
cmake* CMakeInstance;
|
cmake* CMakeInstance;
|
||||||
|
std::vector<std::string> Locations;
|
||||||
|
std::vector<std::string> OutputLocations;
|
||||||
std::vector<PositionType> ParentPositions;
|
std::vector<PositionType> ParentPositions;
|
||||||
std::string SourceDirectory;
|
std::string SourceDirectory;
|
||||||
std::string BinaryDirectory;
|
std::string BinaryDirectory;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user