diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index f303f16fd..3f63646bb 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -17,6 +17,7 @@ #include "cmMakefile.h" #include "cmGeneratedFileStream.h" #include "cmTarget.h" +#include "cmSourceFile.h" #include "cmSystemTools.h" #include @@ -414,7 +415,8 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() linkSourceDirectory.c_str())) { this->AppendLinkedResource(fout, sourceLinkedResourceName, - this->GetEclipsePath(linkSourceDirectory)); + this->GetEclipsePath(linkSourceDirectory), + LinkToFolder); this->SrcLinkedResources.push_back(sourceLinkedResourceName); } @@ -425,7 +427,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() // for each sub project create a linked resource to the source dir // - only if it is an out-of-source build this->AppendLinkedResource(fout, "[Subprojects]", - "virtual:/virtual", true); + "virtual:/virtual", VirtualFolder); for (std::map >::const_iterator it = this->GlobalGenerator->GetProjectMap().begin(); @@ -443,10 +445,92 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() std::string linkName = "[Subprojects]/"; linkName += it->first; this->AppendLinkedResource(fout, linkName, - this->GetEclipsePath(linkSourceDirectory)); + this->GetEclipsePath(linkSourceDirectory), + LinkToFolder + ); this->SrcLinkedResources.push_back(it->first); } } + + 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; + } + } + } } // I'm not sure this makes too much sense. There can be different @@ -1115,20 +1199,25 @@ void cmExtraEclipseCDT4Generator ::AppendLinkedResource (cmGeneratedFileStream& fout, const std::string& name, const std::string& path, - bool isVirtualFolder) + LinkType linkType) { const char* locationTag = "location"; - if (isVirtualFolder) // ... and not a linked folder + const char* typeTag = "2"; + if (linkType == VirtualFolder) // ... and not a linked folder { locationTag = "locationURI"; } + if (linkType == LinkToFile) + { + typeTag = "1"; + } fout << "\t\t\n" "\t\t\t" << cmExtraEclipseCDT4Generator::EscapeForXML(name) << "\n" - "\t\t\t2\n" + "\t\t\t" << typeTag << "\n" "\t\t\t<" << locationTag << ">" << cmExtraEclipseCDT4Generator::EscapeForXML(path) << "\n" @@ -1177,7 +1266,7 @@ bool cmExtraEclipseCDT4Generator else { this->AppendLinkedResource(fout, name, - this->GetEclipsePath(outputPath)); + this->GetEclipsePath(outputPath), LinkToFolder); this->OutLinkedResources.push_back(name); return true; } diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index b86661971..2c7aa4398 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -25,6 +25,8 @@ class cmGeneratedFileStream; class cmExtraEclipseCDT4Generator : public cmExternalMakefileProjectGenerator { public: + enum LinkType {VirtualFolder, LinkToFolder, LinkToFile }; + cmExtraEclipseCDT4Generator(); static cmExternalMakefileProjectGenerator* New() { @@ -88,7 +90,7 @@ private: static void AppendLinkedResource (cmGeneratedFileStream& fout, const std::string& name, const std::string& path, - bool isVirtualFolder = false); + LinkType linkType); bool AppendOutLinkedResource(cmGeneratedFileStream& fout, const std::string& defname,