summaryrefslogtreecommitdiffstats
path: root/Source/cmExtraEclipseCDT4Generator.cxx
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2009-09-16 18:37:21 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2009-09-16 18:37:21 (GMT)
commit9d967ed47b69669e6eb4996ab3e76f5a6151464d (patch)
tree01940929d69d76e66ef15ae3cd883800643af210 /Source/cmExtraEclipseCDT4Generator.cxx
parent72f524efc18ce1d3b488ba544e21554ffd6d61c3 (diff)
downloadCMake-9d967ed47b69669e6eb4996ab3e76f5a6151464d.zip
CMake-9d967ed47b69669e6eb4996ab3e76f5a6151464d.tar.gz
CMake-9d967ed47b69669e6eb4996ab3e76f5a6151464d.tar.bz2
Put compiler defined macros into eclipse project files
Now gcc is queried also for the builtin definitions, and they are then added to the .cproject file. This should make the preprocessor highlighting in eclipse work better (#9272) Patch mostly from Miguel. Alex
Diffstat (limited to 'Source/cmExtraEclipseCDT4Generator.cxx')
-rw-r--r--Source/cmExtraEclipseCDT4Generator.cxx69
1 files changed, 69 insertions, 0 deletions
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index a21df66..b7daab6 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -574,6 +574,75 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
}
}
}
+ // add system defined c macros
+ const char* cDefs=mf->GetDefinition("CMAKE_ECLIPSE_C_SYSTEM_DEFINED_MACROS");
+ if(cDefs)
+ {
+ // Expand the list.
+ std::vector<std::string> defs;
+ cmSystemTools::ExpandListArgument(cDefs, defs, true);
+
+ // the list must contain only definition-value pairs:
+ if ((defs.size() % 2) == 0)
+ {
+ std::vector<std::string>::const_iterator di = defs.begin();
+ while (di != defs.end())
+ {
+ std::string def = *di;
+ ++di;
+ std::string val;
+ if (di != defs.end())
+ {
+ val = *di;
+ ++di;
+ }
+
+ // insert the definition if not already added.
+ if(emmited.find(def) == emmited.end())
+ {
+ emmited.insert(def);
+ fout << "<pathentry kind=\"mac\" name=\"" << def
+ << "\" path=\"\" value=\"" << this->EscapeForXML(val)
+ << "\"/>\n";
+ }
+ }
+ }
+ }
+ // add system defined c++ macros
+ const char* cxxDefs = mf->GetDefinition(
+ "CMAKE_ECLIPSE_CXX_SYSTEM_DEFINED_MACROS");
+ if(cxxDefs)
+ {
+ // Expand the list.
+ std::vector<std::string> defs;
+ cmSystemTools::ExpandListArgument(cxxDefs, defs, true);
+
+ // the list must contain only definition-value pairs:
+ if ((defs.size() % 2) == 0)
+ {
+ std::vector<std::string>::const_iterator di = defs.begin();
+ while (di != defs.end())
+ {
+ std::string def = *di;
+ ++di;
+ std::string val;
+ if (di != defs.end())
+ {
+ val = *di;
+ ++di;
+ }
+
+ // insert the definition if not already added.
+ if(emmited.find(def) == emmited.end())
+ {
+ emmited.insert(def);
+ fout << "<pathentry kind=\"mac\" name=\"" << def
+ << "\" path=\"\" value=\"" << this->EscapeForXML(val)
+ << "\"/>\n";
+ }
+ }
+ }
+ }
// include dirs
emmited.clear();