diff options
author | Brad King <brad.king@kitware.com> | 2004-10-27 16:05:33 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2004-10-27 16:05:33 (GMT) |
commit | 72e125ca1f9cdb28f561b64b0fa15cf090de3972 (patch) | |
tree | 3d2fe588e323ae57899e5520e0f8d3c0ac0435da | |
parent | cc5c136cb824238e426288381a302a6093a3c080 (diff) | |
download | CMake-72e125ca1f9cdb28f561b64b0fa15cf090de3972.zip CMake-72e125ca1f9cdb28f561b64b0fa15cf090de3972.tar.gz CMake-72e125ca1f9cdb28f561b64b0fa15cf090de3972.tar.bz2 |
ENH: Do not try to handle unimplemented target types yet. Fixes for projects with subdirectories.
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator2.cxx | 93 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator2.h | 1 |
2 files changed, 69 insertions, 25 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator2.cxx b/Source/cmLocalUnixMakefileGenerator2.cxx index 6e90fd8..4da5c4a 100644 --- a/Source/cmLocalUnixMakefileGenerator2.cxx +++ b/Source/cmLocalUnixMakefileGenerator2.cxx @@ -45,7 +45,14 @@ void cmLocalUnixMakefileGenerator2::Generate(bool fromTheTop) const cmTargets& targets = m_Makefile->GetTargets(); for(cmTargets::const_iterator t = targets.begin(); t != targets.end(); ++t) { - this->GenerateTargetRuleFile(t->second); + // TODO: Dispatch generation of each target type. + if((t->second.GetType() == cmTarget::EXECUTABLE) || + (t->second.GetType() == cmTarget::STATIC_LIBRARY) || + (t->second.GetType() == cmTarget::SHARED_LIBRARY) || + (t->second.GetType() == cmTarget::MODULE_LIBRARY)) + { + this->GenerateTargetRuleFile(t->second); + } } // Generate the main makefile. @@ -131,13 +138,20 @@ void cmLocalUnixMakefileGenerator2::GenerateMakefile() std::vector<std::string> commands; for(cmTargets::const_iterator t = targets.begin(); t != targets.end(); ++t) { - if(t->second.IsInAll()) + // TODO: Dispatch generation of each target type. + if((t->second.GetType() == cmTarget::EXECUTABLE) || + (t->second.GetType() == cmTarget::STATIC_LIBRARY) || + (t->second.GetType() == cmTarget::SHARED_LIBRARY) || + (t->second.GetType() == cmTarget::MODULE_LIBRARY)) { - std::string dep = this->GetTargetDirectory(t->second); - dep += "/"; - dep += t->first; - dep += ".depends"; - depends.push_back(dep); + if(t->second.IsInAll()) + { + std::string dep = this->GetTargetDirectory(t->second); + dep += "/"; + dep += t->first; + dep += ".depends"; + depends.push_back(dep); + } } } this->OutputMakeRule(makefileStream, "all dependencies", "all.depends", @@ -150,9 +164,16 @@ void cmLocalUnixMakefileGenerator2::GenerateMakefile() std::vector<std::string> commands; for(cmTargets::const_iterator t = targets.begin(); t != targets.end(); ++t) { - if(t->second.IsInAll()) + // TODO: Dispatch generation of each target type. + if((t->second.GetType() == cmTarget::EXECUTABLE) || + (t->second.GetType() == cmTarget::STATIC_LIBRARY) || + (t->second.GetType() == cmTarget::SHARED_LIBRARY) || + (t->second.GetType() == cmTarget::MODULE_LIBRARY)) { - depends.push_back(t->first+".requires"); + if(t->second.IsInAll()) + { + depends.push_back(t->first+".requires"); + } } } this->OutputMakeRule(makefileStream, "all", "all", @@ -164,14 +185,21 @@ void cmLocalUnixMakefileGenerator2::GenerateMakefile() << "# Include target rule files.\n"; for(cmTargets::const_iterator t = targets.begin(); t != targets.end(); ++t) { - std::string ruleFileName = this->GetTargetDirectory(t->second); - ruleFileName += "/"; - ruleFileName += t->first; - ruleFileName += ".make"; - makefileStream - << m_IncludeDirective << " " - << this->ConvertToOutputForExisting(ruleFileName.c_str()).c_str() - << "\n"; + // TODO: Dispatch generation of each target type. + if((t->second.GetType() == cmTarget::EXECUTABLE) || + (t->second.GetType() == cmTarget::STATIC_LIBRARY) || + (t->second.GetType() == cmTarget::SHARED_LIBRARY) || + (t->second.GetType() == cmTarget::MODULE_LIBRARY)) + { + std::string ruleFileName = this->GetTargetDirectory(t->second); + ruleFileName += "/"; + ruleFileName += t->first; + ruleFileName += ".make"; + makefileStream + << m_IncludeDirective << " " + << this->ConvertToOutputForExisting(ruleFileName.c_str()).c_str() + << "\n"; + } } // Write jump-and-build rules that were recorded in the map. @@ -238,7 +266,7 @@ cmLocalUnixMakefileGenerator2 { // Create a directory for this target. std::string dir = this->GetTargetDirectory(target); - cmSystemTools::MakeDirectory(dir.c_str()); + cmSystemTools::MakeDirectory(this->ConvertToFullPath(dir).c_str()); // First generate the object rule files. Save a list of all object // files for this target. @@ -264,9 +292,10 @@ cmLocalUnixMakefileGenerator2 depFileName += "/"; depFileName += target.GetName(); depFileName += ".depends.make"; - if(!cmSystemTools::FileExists(depFileName.c_str())) + std::string depFileNameFull = this->ConvertToFullPath(depFileName); + if(!cmSystemTools::FileExists(depFileNameFull.c_str())) { - std::ofstream depFileStream(depFileName.c_str()); + std::ofstream depFileStream(depFileNameFull.c_str()); this->WriteDisclaimer(depFileStream); depFileStream << "# Empty dependencies file for target " << target.GetName() << ".\n" @@ -279,7 +308,8 @@ cmLocalUnixMakefileGenerator2 ruleFileName += "/"; ruleFileName += target.GetName(); ruleFileName += ".make"; - cmGeneratedFileStream ruleFile(ruleFileName.c_str()); + std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName); + cmGeneratedFileStream ruleFile(ruleFileNameFull.c_str()); std::ostream& ruleFileStream = ruleFile.GetStream(); if(!ruleFileStream) { @@ -402,14 +432,15 @@ cmLocalUnixMakefileGenerator2 // Create the directory containing the object file. This may be a // subdirectory under the target's directory. std::string dir = cmSystemTools::GetFilenamePath(obj.c_str()); - cmSystemTools::MakeDirectory(dir.c_str()); + cmSystemTools::MakeDirectory(this->ConvertToFullPath(dir).c_str()); // If there is no dependencies file, create an empty one. std::string depFileName = obj; depFileName += ".depends.make"; - if(!cmSystemTools::FileExists(depFileName.c_str())) + std::string depFileNameFull = this->ConvertToFullPath(depFileName); + if(!cmSystemTools::FileExists(depFileNameFull.c_str())) { - std::ofstream depFileStream(depFileName.c_str()); + std::ofstream depFileStream(depFileNameFull.c_str()); this->WriteDisclaimer(depFileStream); depFileStream << "# Empty dependencies file for object file " << obj.c_str() << ".\n" @@ -420,7 +451,8 @@ cmLocalUnixMakefileGenerator2 // because the rules may depend on this file itself. std::string ruleFileName = obj; ruleFileName += ".make"; - cmGeneratedFileStream ruleFile(ruleFileName.c_str()); + std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName); + cmGeneratedFileStream ruleFile(ruleFileNameFull.c_str()); std::ostream& ruleFileStream = ruleFile.GetStream(); if(!ruleFileStream) { @@ -1031,6 +1063,17 @@ cmLocalUnixMakefileGenerator2 } //---------------------------------------------------------------------------- +std::string +cmLocalUnixMakefileGenerator2 +::ConvertToFullPath(const std::string& localPath) +{ + std::string dir = m_Makefile->GetCurrentOutputDirectory(); + dir += "/"; + dir += localPath; + return dir; +} + +//---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator2::AddLanguageFlags(std::string& flags, const char* lang) { diff --git a/Source/cmLocalUnixMakefileGenerator2.h b/Source/cmLocalUnixMakefileGenerator2.h index a1e72a2..69f7c75 100644 --- a/Source/cmLocalUnixMakefileGenerator2.h +++ b/Source/cmLocalUnixMakefileGenerator2.h @@ -85,6 +85,7 @@ protected: std::string GetObjectFileName(const cmTarget& target, const cmSourceFile& source); const char* GetSourceFileLanguage(const cmSourceFile& source); + std::string ConvertToFullPath(const std::string& localPath); void AddLanguageFlags(std::string& flags, const char* lang); void AddSharedFlags(std::string& flags, const char* lang, bool shared); |