diff options
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 077470d..c060505 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,13 +1491,6 @@ void cmMakefile::AddLinkLibrary(const std::string& lib) void cmMakefile::InitializeFromParent(cmMakefile* parent) { - this->StateSnapshot.InitializeFromParent(); - - this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", - this->GetCurrentSourceDirectory()); - this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", - this->GetCurrentBinaryDirectory()); - this->SystemIncludeDirectories = parent->SystemIncludeDirectories; // define flags @@ -1749,12 +1761,12 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, this->ContextStack.back()->Name, this->ContextStack.back()->Line); + newSnapshot.GetDirectory().SetCurrentSource(srcPath); + newSnapshot.GetDirectory().SetCurrentBinary(binPath); + cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot); this->GetGlobalGenerator()->AddMakefile(subMf); - // set the subdirs start dirs - subMf->SetCurrentSourceDirectory(srcPath); - subMf->SetCurrentBinaryDirectory(binPath); if(excludeFromAll) { subMf->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); @@ -1770,26 +1782,11 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, } } -void cmMakefile::SetCurrentSourceDirectory(const std::string& dir) -{ - this->StateSnapshot.GetDirectory().SetCurrentSource(dir); - this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", - this->StateSnapshot.GetDirectory().GetCurrentSource()); -} - const char* cmMakefile::GetCurrentSourceDirectory() const { return this->StateSnapshot.GetDirectory().GetCurrentSource(); } -void cmMakefile::SetCurrentBinaryDirectory(const std::string& dir) -{ - this->StateSnapshot.GetDirectory().SetCurrentBinary(dir); - const char* binDir = this->StateSnapshot.GetDirectory().GetCurrentBinary(); - cmSystemTools::MakeDirectory(binDir); - this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", binDir); -} - const char* cmMakefile::GetCurrentBinaryDirectory() const { return this->StateSnapshot.GetDirectory().GetCurrentBinary(); |