summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-11-20 14:08:34 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2013-11-20 14:08:34 (GMT)
commit7df3a10a5e414960633f401151d6042b64375c3a (patch)
tree97e166341b524fc835899d03104b783a07d51ed0 /Source
parent483b7e709396122c2e235972902a65e34878ae2a (diff)
parenta990722b5a8fc15058e7024ec54885ec24ed4bbf (diff)
downloadCMake-7df3a10a5e414960633f401151d6042b64375c3a.zip
CMake-7df3a10a5e414960633f401151d6042b64375c3a.tar.gz
CMake-7df3a10a5e414960633f401151d6042b64375c3a.tar.bz2
Merge topic 'dev/better-eclipse-language-support'
a990722 eclipse: Support custom natures via a global property 51726cc eclipse: Add natures for Eclipse based on enabled languages 4a352d4 Notify extra generators about languages
Diffstat (limited to 'Source')
-rw-r--r--Source/cmExternalMakefileProjectGenerator.cxx6
-rw-r--r--Source/cmExternalMakefileProjectGenerator.h2
-rw-r--r--Source/cmExtraEclipseCDT4Generator.cxx50
-rw-r--r--Source/cmExtraEclipseCDT4Generator.h3
-rw-r--r--Source/cmGlobalGenerator.cxx5
5 files changed, 60 insertions, 6 deletions
diff --git a/Source/cmExternalMakefileProjectGenerator.cxx b/Source/cmExternalMakefileProjectGenerator.cxx
index 9c965cc..0d42c35 100644
--- a/Source/cmExternalMakefileProjectGenerator.cxx
+++ b/Source/cmExternalMakefileProjectGenerator.cxx
@@ -13,6 +13,12 @@
#include "cmExternalMakefileProjectGenerator.h"
+void cmExternalMakefileProjectGenerator
+::EnableLanguage(std::vector<std::string> const&,
+ cmMakefile *, bool)
+{
+}
+
std::string cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
const char* globalGenerator,
const char* extraGenerator)
diff --git a/Source/cmExternalMakefileProjectGenerator.h b/Source/cmExternalMakefileProjectGenerator.h
index 182c1a8..bce441d 100644
--- a/Source/cmExternalMakefileProjectGenerator.h
+++ b/Source/cmExternalMakefileProjectGenerator.h
@@ -41,6 +41,8 @@ public:
/** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry,
const char* fullName) const = 0;
+ virtual void EnableLanguage(std::vector<std::string> const& languages,
+ cmMakefile *, bool optional);
///! set the global generator which will generate the makefiles
virtual void SetGlobalGenerator(cmGlobalGenerator* generator)
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index 676d4ed..755b445 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,28 @@ 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";
+ }
+
+ if (const char *extraNaturesProp = mf->GetCMakeInstance()->
+ GetProperty("ECLIPSE_EXTRA_NATURES", cmProperty::GLOBAL))
+ {
+ std::vector<std::string> extraNatures;
+ cmSystemTools::ExpandListArgument(extraNaturesProp, extraNatures);
+ for (std::vector<std::string>::const_iterator nit = extraNatures.begin();
+ nit != extraNatures.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;
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 65a7118..56db0ef 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -695,6 +695,11 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
{
mf->ReadListFile(0,projectCompatibility.c_str());
}
+ // Inform any extra generator of the new language.
+ if (this->ExtraGenerator)
+ {
+ this->ExtraGenerator->EnableLanguage(languages, mf, false);
+ }
if(fatalError)
{