summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-10-13 19:57:54 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-10-13 22:16:07 (GMT)
commit841164cb36650574a1a7363c78e4cdf28d5d37fd (patch)
tree2bb2395b9077969517ffd7751076697d11fce98e
parent2c219bafc045dfdf49529b8ad141fed3dbb4d8e9 (diff)
downloadCMake-841164cb36650574a1a7363c78e4cdf28d5d37fd.zip
CMake-841164cb36650574a1a7363c78e4cdf28d5d37fd.tar.gz
CMake-841164cb36650574a1a7363c78e4cdf28d5d37fd.tar.bz2
cmState: Initialize current directories immediately.
Don't leave this as cmMakefile responsibility.
-rw-r--r--Source/cmMakefile.cxx28
-rw-r--r--Source/cmState.cxx8
2 files changed, 10 insertions, 26 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 2c5501e..f804d06 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -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);
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 9de58d8..e3f62b5 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -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()