From c3f30bdd63682b4ba7166e23b3b3dc38548aab07 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 23 Oct 2011 12:22:20 +0200 Subject: [PATCH] Eclipse: move code for generating links to targets into separate function Alex --- Source/cmExtraEclipseCDT4Generator.cxx | 162 +++++++++++++------------ Source/cmExtraEclipseCDT4Generator.h | 2 +- 2 files changed, 84 insertions(+), 80 deletions(-) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index c1a810bba..9fc9e169a 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -426,85 +426,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() { this->CreateLinksToSubprojects(fout); - std::string linkName = "[Targets]"; - this->AppendLinkedResource(fout, linkName, "virtual:/virtual", - VirtualFolder); - - - for (std::vector::const_iterator - lgIt = this->GlobalGenerator->GetLocalGenerators().begin(); - lgIt != this->GlobalGenerator->GetLocalGenerators().end(); - ++lgIt) - { - cmMakefile* makefile = (*lgIt)->GetMakefile(); - const cmTargets& targets = makefile->GetTargets(); - - for(cmTargets::const_iterator ti=targets.begin(); ti!=targets.end();++ti) - { - std::string linkName2 = linkName; - linkName2 += "/"; - switch(ti->second.GetType()) - { - case cmTarget::EXECUTABLE: - case cmTarget::STATIC_LIBRARY: - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: - { - const char* prefix = (ti->second.GetType()==cmTarget::EXECUTABLE ? - "[exe] " : "[lib] "); - linkName2 += prefix; - linkName2 += ti->first; - this->AppendLinkedResource(fout, linkName2, "virtual:/virtual", - VirtualFolder); - std::vector sourceGroups = - makefile->GetSourceGroups(); - // get the files from the source lists then add them to the groups - cmTarget* tgt = const_cast(&ti->second); - std::vectorconst & files = tgt->GetSourceFiles(); - for(std::vector::const_iterator sfIt = files.begin(); - sfIt != files.end(); - sfIt++) - { - // Add the file to the list of sources. - std::string source = (*sfIt)->GetFullPath(); - cmSourceGroup& sourceGroup = - makefile->FindSourceGroup(source.c_str(), sourceGroups); - sourceGroup.AssignSource(*sfIt); - } - - - for(std::vector::iterator sgIt=sourceGroups.begin(); - sgIt != sourceGroups.end(); - ++sgIt) - { - std::string linkName3 = linkName2; - linkName3 += "/"; - linkName3 += sgIt->GetFullName(); - this->AppendLinkedResource(fout, linkName3, "virtual:/virtual", - VirtualFolder); - - std::vector sFiles = sgIt->GetSourceFiles(); - for(std::vector::const_iterator fileIt = - sFiles.begin(); - fileIt != sFiles.end(); - ++fileIt) - { - std::string linkName4 = linkName3; - linkName4 += "/"; - linkName4 += - cmSystemTools::GetFilenameName((*fileIt)->GetFullPath()); - this->AppendLinkedResource(fout, linkName4, - (*fileIt)->GetFullPath(), LinkToFile); - } - } - } - break; - // ignore all others: - default: - break; - } - } - } + this->CreateLinksForTargets(fout); } // I'm not sure this makes too much sense. There can be different @@ -525,6 +447,88 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() } +//---------------------------------------------------------------------------- +void cmExtraEclipseCDT4Generator::CreateLinksForTargets( + cmGeneratedFileStream& fout) +{ + std::string linkName = "[Targets]"; + this->AppendLinkedResource(fout, linkName, "virtual:/virtual",VirtualFolder); + + for (std::vector::const_iterator + lgIt = this->GlobalGenerator->GetLocalGenerators().begin(); + lgIt != this->GlobalGenerator->GetLocalGenerators().end(); + ++lgIt) + { + cmMakefile* makefile = (*lgIt)->GetMakefile(); + const cmTargets& targets = makefile->GetTargets(); + + for(cmTargets::const_iterator ti=targets.begin(); ti!=targets.end();++ti) + { + std::string linkName2 = linkName; + linkName2 += "/"; + switch(ti->second.GetType()) + { + case cmTarget::EXECUTABLE: + case cmTarget::STATIC_LIBRARY: + case cmTarget::SHARED_LIBRARY: + case cmTarget::MODULE_LIBRARY: + { + const char* prefix = (ti->second.GetType()==cmTarget::EXECUTABLE ? + "[exe] " : "[lib] "); + linkName2 += prefix; + linkName2 += ti->first; + this->AppendLinkedResource(fout, linkName2, "virtual:/virtual", + VirtualFolder); + std::vector sourceGroups=makefile->GetSourceGroups(); + // get the files from the source lists then add them to the groups + cmTarget* tgt = const_cast(&ti->second); + std::vectorconst & files = tgt->GetSourceFiles(); + for(std::vector::const_iterator sfIt = files.begin(); + sfIt != files.end(); + sfIt++) + { + // Add the file to the list of sources. + std::string source = (*sfIt)->GetFullPath(); + cmSourceGroup& sourceGroup = + makefile->FindSourceGroup(source.c_str(), sourceGroups); + sourceGroup.AssignSource(*sfIt); + } + + for(std::vector::iterator sgIt = sourceGroups.begin(); + sgIt != sourceGroups.end(); + ++sgIt) + { + std::string linkName3 = linkName2; + linkName3 += "/"; + linkName3 += sgIt->GetFullName(); + this->AppendLinkedResource(fout, linkName3, "virtual:/virtual", + VirtualFolder); + + std::vector sFiles = sgIt->GetSourceFiles(); + for(std::vector::const_iterator fileIt = + sFiles.begin(); + fileIt != sFiles.end(); + ++fileIt) + { + std::string linkName4 = linkName3; + linkName4 += "/"; + linkName4 += + cmSystemTools::GetFilenameName((*fileIt)->GetFullPath()); + this->AppendLinkedResource(fout, linkName4, + (*fileIt)->GetFullPath(), LinkToFile); + } + } + } + break; + // ignore all others: + default: + break; + } + } + } +} + + //---------------------------------------------------------------------------- void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects( cmGeneratedFileStream& fout) diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index 5a1a45341..ac2de16b5 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -104,7 +104,7 @@ private: cmMakefile* mf); void CreateLinksToSubprojects(cmGeneratedFileStream& fout); - + void CreateLinksForTargets(cmGeneratedFileStream& fout); std::vector SrcLinkedResources; std::vector OutLinkedResources;