diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2013-08-29 18:46:17 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2013-11-19 16:48:19 (GMT) |
commit | 51726cce64ee8bce1115f3c6d092b4ae6f43d714 (patch) | |
tree | 4603d3738bb49933117e135c55c66303d8f03bac | |
parent | 4a352d43bbe3c8726046683e7dbc89a55b5e1c67 (diff) | |
download | CMake-51726cce64ee8bce1115f3c6d092b4ae6f43d714.zip CMake-51726cce64ee8bce1115f3c6d092b4ae6f43d714.tar.gz CMake-51726cce64ee8bce1115f3c6d092b4ae6f43d714.tar.bz2 |
eclipse: Add natures for Eclipse based on enabled languages
Also adds support for the Java nature if Java is being used.
-rw-r--r-- | Source/cmExtraEclipseCDT4Generator.cxx | 38 | ||||
-rw-r--r-- | Source/cmExtraEclipseCDT4Generator.h | 3 |
2 files changed, 35 insertions, 6 deletions
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 676d4ed..effc38c 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -51,6 +51,29 @@ void cmExtraEclipseCDT4Generator } //---------------------------------------------------------------------------- +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() { const cmMakefile* mf @@ -433,13 +456,16 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() // set natures for c/c++ projects fout << "\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.ScannerConfigNature</nature>\n" - "\t\t<nature>org.eclipse.cdt.core.cnature</nature>\n" - "\t</natures>\n" - ; + "\t\t<nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>\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"; // create linked resources diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index b31cce7..9c89f85 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -41,6 +41,8 @@ public: virtual void GetDocumentation(cmDocumentationEntry& entry, const char* fullName) const; + virtual void EnableLanguage(std::vector<std::string> const& languages, + cmMakefile *, bool optional); virtual void Generate(); @@ -105,6 +107,7 @@ private: void CreateLinksForTargets(cmGeneratedFileStream& fout); std::vector<std::string> SrcLinkedResources; + std::set<std::string> Natures; std::string HomeDirectory; std::string HomeOutputDirectory; bool IsOutOfSourceBuild; |