improve system/compiler specific settings of Eclipse

-use CMAKE_EXECUTABLE_FORMAT and CMAKE_SYSTEM_NAME to decide which binary
parsers to load (ELF/Mach O/PE)
-use CMAKE_(C|CXX)_COMPILER_ID to load the respective compiler error parser
-remove EclipseToolchainType, which was a mixture between compiler and operating system

Alex
This commit is contained in:
Alexander Neundorf 2009-11-22 05:01:04 -05:00
parent 892accffba
commit 2d9c72c7e5
2 changed files with 41 additions and 81 deletions

View File

@ -285,10 +285,19 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
"\t\t\t\t\t<key>org.eclipse.cdt.core.errorOutputParser</key>\n" "\t\t\t\t\t<key>org.eclipse.cdt.core.errorOutputParser</key>\n"
"\t\t\t\t\t<value>" "\t\t\t\t\t<value>"
; ;
if (this->GetToolChainType(*mf) == EclipseToolchainOther) std::string compilerId = mf->GetSafeDefinition("CMAKE_C_COMPILER_ID");
if (compilerId.empty()) // no C compiler, try the C++ compiler:
{
compilerId = mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID");
}
if (compilerId == "MSVC")
{ {
fout << "org.eclipse.cdt.core.VCErrorParser;"; fout << "org.eclipse.cdt.core.VCErrorParser;";
} }
else if (compilerId == "Intel")
{
fout << "org.eclipse.cdt.core.ICCErrorParser;";
}
fout << fout <<
"org.eclipse.cdt.core.MakeErrorParser;" "org.eclipse.cdt.core.MakeErrorParser;"
"org.eclipse.cdt.core.GCCErrorParser;" "org.eclipse.cdt.core.GCCErrorParser;"
@ -418,20 +427,25 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
"<extensions>\n" "<extensions>\n"
; ;
// TODO: refactor this out... // TODO: refactor this out...
switch (this->GetToolChainType(*mf)) std::string executableFormat = mf->GetSafeDefinition(
{ "CMAKE_EXECUTABLE_FORMAT");
case EclipseToolchainLinux : if (executableFormat == "ELF")
fout << "<extension id=\"org.eclipse.cdt.core.ELF\"" {
" point=\"org.eclipse.cdt.core.BinaryParser\"/>\n" fout << "<extension id=\"org.eclipse.cdt.core.ELF\""
; " point=\"org.eclipse.cdt.core.BinaryParser\"/>\n"
fout << "<extension id=\"org.eclipse.cdt.core.GNU_ELF\"" ;
" point=\"org.eclipse.cdt.core.BinaryParser\">\n" fout << "<extension id=\"org.eclipse.cdt.core.GNU_ELF\""
"<attribute key=\"addr2line\" value=\"addr2line\"/>\n" " point=\"org.eclipse.cdt.core.BinaryParser\">\n"
"<attribute key=\"c++filt\" value=\"c++filt\"/>\n" "<attribute key=\"addr2line\" value=\"addr2line\"/>\n"
"</extension>\n" "<attribute key=\"c++filt\" value=\"c++filt\"/>\n"
; "</extension>\n"
break; ;
case EclipseToolchainCygwin : }
else
{
std::string systemName = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME");
if (systemName == "CYGWIN")
{
fout << "<extension id=\"org.eclipse.cdt.core.Cygwin_PE\"" fout << "<extension id=\"org.eclipse.cdt.core.Cygwin_PE\""
" point=\"org.eclipse.cdt.core.BinaryParser\">\n" " point=\"org.eclipse.cdt.core.BinaryParser\">\n"
"<attribute key=\"addr2line\" value=\"addr2line\"/>\n" "<attribute key=\"addr2line\" value=\"addr2line\"/>\n"
@ -440,36 +454,28 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
"<attribute key=\"nm\" value=\"nm\"/>\n" "<attribute key=\"nm\" value=\"nm\"/>\n"
"</extension>\n" "</extension>\n"
; ;
break; }
case EclipseToolchainMinGW : else if (systemName == "Windows")
{
fout << "<extension id=\"org.eclipse.cdt.core.PE\"" fout << "<extension id=\"org.eclipse.cdt.core.PE\""
" point=\"org.eclipse.cdt.core.BinaryParser\"/>\n" " point=\"org.eclipse.cdt.core.BinaryParser\"/>\n"
; ;
break; }
case EclipseToolchainSolaris : else if (systemName == "Darwin")
fout << "<extension id=\"org.eclipse.cdt.core.ELF\"" {
" point=\"org.eclipse.cdt.core.BinaryParser\"/>\n"
;
break;
case EclipseToolchainMacOSX :
fout << "<extension id=\"org.eclipse.cdt.core.MachO\"" fout << "<extension id=\"org.eclipse.cdt.core.MachO\""
" point=\"org.eclipse.cdt.core.BinaryParser\">\n" " point=\"org.eclipse.cdt.core.BinaryParser\">\n"
"<attribute key=\"c++filt\" value=\"c++filt\"/>\n" "<attribute key=\"c++filt\" value=\"c++filt\"/>\n"
"</extension>\n" "</extension>\n"
; ;
break; }
case EclipseToolchainOther : else
fout << "<extension id=\"org.eclipse.cdt.core.PE\"" {
" point=\"org.eclipse.cdt.core.BinaryParser\"/>\n"
;
fout << "<extension id=\"org.eclipse.cdt.core.ELF\""
" point=\"org.eclipse.cdt.core.BinaryParser\"/>\n"
;
break;
default :
// *** Should never get here *** // *** Should never get here ***
fout << "<error_toolchain_type/>\n"; fout << "<error_toolchain_type/>\n";
} }
}
fout << "</extensions>\n" fout << "</extensions>\n"
"</storageModule>\n" "</storageModule>\n"
; ;
@ -828,40 +834,6 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmExtraEclipseCDT4Generator::EclipseToolchainType
cmExtraEclipseCDT4Generator::GetToolChainType(const cmMakefile& makefile)
{
if (makefile.IsSet("UNIX"))
{
if (makefile.IsSet("CYGWIN"))
{
return EclipseToolchainCygwin;
}
if (makefile.IsSet("APPLE" ))
{
return EclipseToolchainMacOSX;
}
// *** how do I determine if it is Solaris ???
return EclipseToolchainLinux;
}
else if (makefile.IsSet("WIN32"))
{
if (makefile.IsSet("MINGW"))
{
return EclipseToolchainMinGW;
}
if (makefile.IsSet("MSYS" ))
{
return EclipseToolchainMinGW;
}
return EclipseToolchainOther;
}
else
{
return EclipseToolchainOther;
}
}
std::string std::string
cmExtraEclipseCDT4Generator::GetEclipsePath(const std::string& path) cmExtraEclipseCDT4Generator::GetEclipsePath(const std::string& path)
{ {

View File

@ -56,18 +56,6 @@ private:
// create .cproject file // create .cproject file
void CreateCProjectFile() const; void CreateCProjectFile() const;
// Eclipse supported toolchain types
enum EclipseToolchainType
{
EclipseToolchainOther,
EclipseToolchainLinux,
EclipseToolchainCygwin,
EclipseToolchainMinGW,
EclipseToolchainSolaris,
EclipseToolchainMacOSX
};
static EclipseToolchainType GetToolChainType(const cmMakefile& makefile);
// If built with cygwin cmake, convert posix to windows path. // If built with cygwin cmake, convert posix to windows path.
static std::string GetEclipsePath(const std::string& path); static std::string GetEclipsePath(const std::string& path);