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<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;";
}
else if (compilerId == "Intel")
{
fout << "org.eclipse.cdt.core.ICCErrorParser;";
}
fout <<
"org.eclipse.cdt.core.MakeErrorParser;"
"org.eclipse.cdt.core.GCCErrorParser;"
@ -418,20 +427,25 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
"<extensions>\n"
;
// TODO: refactor this out...
switch (this->GetToolChainType(*mf))
{
case EclipseToolchainLinux :
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"
"<attribute key=\"addr2line\" value=\"addr2line\"/>\n"
"<attribute key=\"c++filt\" value=\"c++filt\"/>\n"
"</extension>\n"
;
break;
case EclipseToolchainCygwin :
std::string executableFormat = mf->GetSafeDefinition(
"CMAKE_EXECUTABLE_FORMAT");
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.GNU_ELF\""
" point=\"org.eclipse.cdt.core.BinaryParser\">\n"
"<attribute key=\"addr2line\" value=\"addr2line\"/>\n"
"<attribute key=\"c++filt\" value=\"c++filt\"/>\n"
"</extension>\n"
;
}
else
{
std::string systemName = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME");
if (systemName == "CYGWIN")
{
fout << "<extension id=\"org.eclipse.cdt.core.Cygwin_PE\""
" point=\"org.eclipse.cdt.core.BinaryParser\">\n"
"<attribute key=\"addr2line\" value=\"addr2line\"/>\n"
@ -440,36 +454,28 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
"<attribute key=\"nm\" value=\"nm\"/>\n"
"</extension>\n"
;
break;
case EclipseToolchainMinGW :
}
else if (systemName == "Windows")
{
fout << "<extension id=\"org.eclipse.cdt.core.PE\""
" point=\"org.eclipse.cdt.core.BinaryParser\"/>\n"
;
break;
case EclipseToolchainSolaris :
fout << "<extension id=\"org.eclipse.cdt.core.ELF\""
" point=\"org.eclipse.cdt.core.BinaryParser\"/>\n"
;
break;
case EclipseToolchainMacOSX :
}
else if (systemName == "Darwin")
{
fout << "<extension id=\"org.eclipse.cdt.core.MachO\""
" point=\"org.eclipse.cdt.core.BinaryParser\">\n"
"<attribute key=\"c++filt\" value=\"c++filt\"/>\n"
"</extension>\n"
;
break;
case EclipseToolchainOther :
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 :
}
else
{
// *** Should never get here ***
fout << "<error_toolchain_type/>\n";
}
}
}
fout << "</extensions>\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
cmExtraEclipseCDT4Generator::GetEclipsePath(const std::string& path)
{

View File

@ -56,18 +56,6 @@ private:
// create .cproject file
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.
static std::string GetEclipsePath(const std::string& path);