summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-05-30 23:57:04 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-10-07 18:19:41 (GMT)
commit360e4e1db0cc89ea4f092eeb1ba1e6df8ee782b7 (patch)
treeddc52c40a5a4124c0441471627a27bdd2c79af00 /Source/cmMakefile.cxx
parentf716460ed82134bd1ca09f49bfa507cb2645d96c (diff)
downloadCMake-360e4e1db0cc89ea4f092eeb1ba1e6df8ee782b7.zip
CMake-360e4e1db0cc89ea4f092eeb1ba1e6df8ee782b7.tar.gz
CMake-360e4e1db0cc89ea4f092eeb1ba1e6df8ee782b7.tar.bz2
Set the current dirs on the snapshot before creating the cmMakefile.
The cmMakefile should get a fully prepared snapshot and not clobber its definitions. It should eventually be able to process list files from any starting-point snapshot, though that is some refactoring away still.
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx47
1 files changed, 30 insertions, 17 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index e522320..11a949f 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -120,15 +120,34 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
#endif
+ this->AddDefinition("CMAKE_SOURCE_DIR",
+ this->GetCMakeInstance()->GetHomeDirectory());
+ this->AddDefinition("CMAKE_BINARY_DIR",
+ this->GetCMakeInstance()->GetHomeOutputDirectory());
{
- const char* dir = this->GetCMakeInstance()->GetHomeDirectory();
- this->AddDefinition("CMAKE_SOURCE_DIR", dir);
- this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", dir);
+ const char* dir = this->StateSnapshot.GetDirectory().GetCurrentSource();
+ if (dir)
+ {
+ this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", dir);
+ }
+ else
+ {
+ this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
+ this->GetCMakeInstance()->GetHomeDirectory());
+ }
}
{
- const char* dir = this->GetCMakeInstance()->GetHomeOutputDirectory();
- this->AddDefinition("CMAKE_BINARY_DIR", dir);
- this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", dir);
+ const char* dir = this->StateSnapshot.GetDirectory().GetCurrentBinary();
+ if (dir)
+ {
+ cmSystemTools::MakeDirectory(dir);
+ this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", dir);
+ }
+ else
+ {
+ this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
+ this->GetCMakeInstance()->GetHomeOutputDirectory());
+ }
}
}
@@ -1472,11 +1491,6 @@ void cmMakefile::AddLinkLibrary(const std::string& lib)
void cmMakefile::InitializeFromParent(cmMakefile* parent)
{
- this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
- this->GetCurrentSourceDirectory());
- this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
- this->GetCurrentBinaryDirectory());
-
this->SystemIncludeDirectories = parent->SystemIncludeDirectories;
// define flags
@@ -1747,14 +1761,13 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
this->ContextStack.back()->Name,
this->ContextStack.back()->Line);
- cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot);
- this->GetGlobalGenerator()->AddMakefile(subMf);
+ newSnapshot.InitializeFromParent();
- // set the subdirs start dirs
- subMf->SetCurrentSourceDirectory(srcPath);
- subMf->SetCurrentBinaryDirectory(binPath);
+ newSnapshot.GetDirectory().SetCurrentSource(srcPath);
+ newSnapshot.GetDirectory().SetCurrentBinary(binPath);
- subMf->StateSnapshot.InitializeFromParent();
+ cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot);
+ this->GetGlobalGenerator()->AddMakefile(subMf);
if(excludeFromAll)
{