diff options
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 81 |
1 files changed, 59 insertions, 22 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 83efc05..c77a90c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -179,11 +179,11 @@ void cmMakefile::Print() const } std::cout << " this->StartOutputDirectory; " << - this->StartOutputDirectory << std::endl; + this->GetCurrentBinaryDirectory() << std::endl; std::cout << " this->HomeOutputDirectory; " << this->HomeOutputDirectory << std::endl; std::cout << " this->cmStartDirectory; " << - this->cmStartDirectory << std::endl; + this->GetCurrentSourceDirectory() << std::endl; std::cout << " this->cmHomeDirectory; " << this->cmHomeDirectory << std::endl; std::cout << " this->ProjectName; " @@ -223,7 +223,7 @@ void cmMakefile::IssueMessage(cmake::MessageType t, if(this->ListFileStack.empty()) { // We are not processing the project. Add the directory-level context. - lfc.FilePath = this->GetCurrentDirectory(); + lfc.FilePath = this->GetCurrentSourceDirectory(); lfc.FilePath += "/CMakeLists.txt"; } else @@ -480,8 +480,9 @@ bool cmMakefile::ProcessBuildsystemFile(const char* listfile) { this->AddDefinition("CMAKE_PARENT_LIST_FILE", listfile); this->cmCurrentListFile = listfile; + std::string curSrc = this->GetCurrentSourceDirectory(); return this->ReadListFile(listfile, true, - this->cmStartDirectory == this->cmHomeDirectory); + curSrc == this->GetHomeDirectory()); } bool cmMakefile::ReadDependentFile(const char* listfile, bool noPolicyScope) @@ -489,7 +490,7 @@ bool cmMakefile::ReadDependentFile(const char* listfile, bool noPolicyScope) this->AddDefinition("CMAKE_PARENT_LIST_FILE", this->GetCurrentListFile()); this->cmCurrentListFile = cmSystemTools::CollapseFullPath(listfile, - this->cmStartDirectory.c_str()); + this->GetCurrentSourceDirectory()); return this->ReadListFile(this->cmCurrentListFile.c_str(), noPolicyScope); } @@ -503,7 +504,7 @@ bool cmMakefile::ReadListFile(const char* listfile, { std::string filenametoread = cmSystemTools::CollapseFullPath(listfile, - this->cmStartDirectory.c_str()); + this->GetCurrentSourceDirectory()); std::string currentParentFile = this->GetSafeDefinition("CMAKE_PARENT_LIST_FILE"); @@ -650,6 +651,9 @@ void cmMakefile::SetLocalGenerator(cmLocalGenerator* lg) this->Properties.SetCMakeInstance(this->GetCMakeInstance()); this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused(); this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars(); + this->SetHomeDirectory(this->GetCMakeInstance()->GetHomeDirectory()); + this->SetHomeOutputDirectory( + this->GetCMakeInstance()->GetHomeOutputDirectory()); } namespace @@ -1187,7 +1191,7 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName, // Store the custom command in the target. if (!commandLines.empty() || !depends.empty()) { - std::string force = this->GetStartOutputDirectory(); + std::string force = this->GetCurrentBinaryDirectory(); force += cmake::GetCMakeFilesDirectory(); force += "/"; force += utilityName; @@ -1497,6 +1501,11 @@ void cmMakefile::InitializeFromParent() // Initialize definitions with the closure of the parent scope. this->Internal->VarStack.top() = parent->Internal->VarStack.top().Closure(); + this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", + this->GetCurrentSourceDirectory()); + this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", + this->GetCurrentBinaryDirectory()); + const std::vector<cmValueWithOrigin>& parentIncludes = parent->GetIncludeDirectoriesEntries(); this->IncludeDirectoriesEntries.insert(this->IncludeDirectoriesEntries.end(), @@ -1565,11 +1574,10 @@ void cmMakefile::InitializeFromParent() void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2) { lg2->GetMakefile()->InitializeFromParent(); - lg2->GetMakefile()->MakeStartDirectoriesCurrent(); if (this->GetCMakeInstance()->GetDebugOutput()) { std::string msg=" Entering "; - msg += lg2->GetMakefile()->GetCurrentDirectory(); + msg += lg2->GetMakefile()->GetCurrentSourceDirectory(); cmSystemTools::Message(msg.c_str()); } // finally configure the subdir @@ -1577,7 +1585,7 @@ void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2) if (this->GetCMakeInstance()->GetDebugOutput()) { std::string msg=" Returning to "; - msg += this->GetCurrentDirectory(); + msg += this->GetCurrentSourceDirectory(); cmSystemTools::Message(msg.c_str()); } } @@ -1600,8 +1608,8 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, this->LocalGenerator->GetGlobalGenerator()->AddLocalGenerator(lg2); // set the subdirs start dirs - lg2->GetMakefile()->SetStartDirectory(srcPath); - lg2->GetMakefile()->SetStartOutputDirectory(binPath); + lg2->GetMakefile()->SetCurrentSourceDirectory(srcPath); + lg2->GetMakefile()->SetCurrentBinaryDirectory(binPath); if(excludeFromAll) { lg2->GetMakefile()->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); @@ -1613,6 +1621,37 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, } } +void cmMakefile::SetCurrentSourceDirectory(const std::string& dir) +{ + this->cmStartDirectory = dir; + cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory); + this->cmStartDirectory = + cmSystemTools::CollapseFullPath(this->cmStartDirectory); + this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", + this->cmStartDirectory.c_str()); +} + +const char* cmMakefile::GetCurrentSourceDirectory() const +{ + return this->cmStartDirectory.c_str(); +} + +void cmMakefile::SetCurrentBinaryDirectory(const std::string& dir) +{ + this->StartOutputDirectory = dir; + cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory); + this->StartOutputDirectory = + cmSystemTools::CollapseFullPath(this->StartOutputDirectory); + cmSystemTools::MakeDirectory(this->StartOutputDirectory.c_str()); + this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", + this->StartOutputDirectory.c_str()); +} + +const char* cmMakefile::GetCurrentBinaryDirectory() const +{ + return this->StartOutputDirectory.c_str(); +} + //---------------------------------------------------------------------------- void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs, bool before) @@ -1809,7 +1848,7 @@ void cmMakefile::CheckForUnused(const char* reason, } else { - path = this->GetStartDirectory(); + path = this->GetCurrentSourceDirectory(); path += "/CMakeLists.txt"; cmListFileContext lfc; lfc.FilePath = path; @@ -3362,9 +3401,9 @@ const char* cmMakefile::GetHomeOutputDirectory() const return this->HomeOutputDirectory.c_str(); } -void cmMakefile::SetHomeOutputDirectory(const std::string& lib) +void cmMakefile::SetHomeOutputDirectory(const std::string& dir) { - this->HomeOutputDirectory = lib; + this->HomeOutputDirectory = dir; cmSystemTools::ConvertToUnixSlashes(this->HomeOutputDirectory); this->AddDefinition("CMAKE_BINARY_DIR", this->GetHomeOutputDirectory()); if ( !this->GetDefinition("CMAKE_CURRENT_BINARY_DIR") ) @@ -3491,8 +3530,6 @@ int cmMakefile::TryCompile(const std::string& srcdir, // do a configure cm.SetHomeDirectory(srcdir); cm.SetHomeOutputDirectory(bindir); - cm.SetStartDirectory(srcdir); - cm.SetStartOutputDirectory(bindir); cm.SetGeneratorPlatform(this->GetCMakeInstance()->GetGeneratorPlatform()); cm.SetGeneratorToolset(this->GetCMakeInstance()->GetGeneratorToolset()); cm.LoadCache(); @@ -3988,8 +4025,8 @@ void cmMakefile::SetProperty(const std::string& prop, const char* value) if ( prop == "ADDITIONAL_MAKE_CLEAN_FILES" ) { // This property is not inherrited - if ( strcmp(this->GetCurrentDirectory(), - this->GetStartDirectory()) != 0 ) + if ( strcmp(this->GetCurrentSourceDirectory(), + this->GetCurrentSourceDirectory()) != 0 ) { return; } @@ -4053,7 +4090,7 @@ const char *cmMakefile::GetProperty(const std::string& prop, { if(cmLocalGenerator* plg = this->LocalGenerator->GetParent()) { - output = plg->GetMakefile()->GetStartDirectory(); + output = plg->GetMakefile()->GetCurrentSourceDirectory(); } return output.c_str(); } @@ -4256,7 +4293,7 @@ void cmMakefile::AddCMakeDependFilesFromUser() } else { - std::string f = this->GetCurrentDirectory(); + std::string f = this->GetCurrentSourceDirectory(); f += "/"; f += *i; this->AddCMakeDependFile(f); @@ -4537,7 +4574,7 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, default: break; } e << "created in source directory \"" - << existing->GetMakefile()->GetCurrentDirectory() << "\". " + << existing->GetMakefile()->GetCurrentSourceDirectory() << "\". " << "See documentation for policy CMP0002 for more details."; msg = e.str(); return false; |