eclipse: Add natures for Eclipse based on enabled languages

Also adds support for the Java nature if Java is being used.
This commit is contained in:
Ben Boeckel 2013-08-29 14:46:17 -04:00
parent 4a352d43bb
commit 51726cce64
2 changed files with 35 additions and 6 deletions

View File

@ -50,6 +50,29 @@ void cmExtraEclipseCDT4Generator
entry.Brief = "Generates Eclipse CDT 4.0 project files."; entry.Brief = "Generates Eclipse CDT 4.0 project files.";
} }
//----------------------------------------------------------------------------
void cmExtraEclipseCDT4Generator
::EnableLanguage(std::vector<std::string> const& languages,
cmMakefile *, bool)
{
for (std::vector<std::string>::const_iterator lit = languages.begin();
lit != languages.end(); ++lit)
{
if (*lit == "CXX")
{
this->Natures.insert("org.eclipse.cdt.core.ccnature");
}
else if (*lit == "C")
{
this->Natures.insert("org.eclipse.cdt.core.cnature");
}
else if (*lit == "Java")
{
this->Natures.insert("org.eclipse.jdt.core.javanature");
}
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmExtraEclipseCDT4Generator::Generate() void cmExtraEclipseCDT4Generator::Generate()
{ {
@ -433,13 +456,16 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
// set natures for c/c++ projects // set natures for c/c++ projects
fout << fout <<
"\t<natures>\n" "\t<natures>\n"
// TODO: ccnature only if it is c++ ???
"\t\t<nature>org.eclipse.cdt.core.ccnature</nature>\n"
"\t\t<nature>org.eclipse.cdt.make.core.makeNature</nature>\n" "\t\t<nature>org.eclipse.cdt.make.core.makeNature</nature>\n"
"\t\t<nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>\n" "\t\t<nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>\n";
"\t\t<nature>org.eclipse.cdt.core.cnature</nature>\n"
"\t</natures>\n" for (std::set<std::string>::const_iterator nit=this->Natures.begin();
; nit != this->Natures.end(); ++nit)
{
fout << "\t\t<nature>" << *nit << "</nature>\n";
}
fout << "\t</natures>\n";
fout << "\t<linkedResources>\n"; fout << "\t<linkedResources>\n";
// create linked resources // create linked resources

View File

@ -41,6 +41,8 @@ public:
virtual void GetDocumentation(cmDocumentationEntry& entry, virtual void GetDocumentation(cmDocumentationEntry& entry,
const char* fullName) const; const char* fullName) const;
virtual void EnableLanguage(std::vector<std::string> const& languages,
cmMakefile *, bool optional);
virtual void Generate(); virtual void Generate();
@ -105,6 +107,7 @@ private:
void CreateLinksForTargets(cmGeneratedFileStream& fout); void CreateLinksForTargets(cmGeneratedFileStream& fout);
std::vector<std::string> SrcLinkedResources; std::vector<std::string> SrcLinkedResources;
std::set<std::string> Natures;
std::string HomeDirectory; std::string HomeDirectory;
std::string HomeOutputDirectory; std::string HomeOutputDirectory;
bool IsOutOfSourceBuild; bool IsOutOfSourceBuild;