CodeBlocks: improve support for different compilers

More elaborate selection of the `compiler` tag in the generated
CodeBlocks project file:

* Fortran language support

* support for several of the predefined compilers recognized by
  CodeBlocks (16.01)
This commit is contained in:
Melven Roehrig-Zoellner 2016-02-12 00:00:10 +01:00 committed by Brad King
parent 8dfb6f8b37
commit 184da3f4f6
1 changed files with 55 additions and 6 deletions

View File

@ -684,18 +684,38 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf) std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf)
{ {
// figure out which language to use // figure out which language to use
// for now care only for C and C++ // for now care only for C, C++, and Fortran
std::string compilerIdVar = "CMAKE_CXX_COMPILER_ID";
if (this->GlobalGenerator->GetLanguageEnabled("CXX") == false) // projects with C/C++ and Fortran are handled as C/C++ projects
bool pureFortran = false;
std::string compilerIdVar;
if (this->GlobalGenerator->GetLanguageEnabled("CXX") == true)
{
compilerIdVar = "CMAKE_CXX_COMPILER_ID";
}
else if (this->GlobalGenerator->GetLanguageEnabled("C") == true)
{ {
compilerIdVar = "CMAKE_C_COMPILER_ID"; compilerIdVar = "CMAKE_C_COMPILER_ID";
} }
else if (this->GlobalGenerator->GetLanguageEnabled("Fortran") == true)
{
compilerIdVar = "CMAKE_Fortran_COMPILER_ID";
pureFortran = true;
}
std::string compilerId = mf->GetSafeDefinition(compilerIdVar); std::string compilerId = mf->GetSafeDefinition(compilerIdVar);
std::string compiler = "gcc"; // default to gcc std::string compiler = "gcc"; // default to gcc
if (compilerId == "MSVC") if (compilerId == "MSVC")
{ {
compiler = "msvc8"; if( mf->IsDefinitionSet("MSVC10") == true )
{
compiler = "msvc10";
}
else
{
compiler = "msvc8";
}
} }
else if (compilerId == "Borland") else if (compilerId == "Borland")
{ {
@ -707,15 +727,44 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf)
} }
else if (compilerId == "Intel") else if (compilerId == "Intel")
{ {
compiler = "icc"; if (pureFortran && mf->IsDefinitionSet("WIN32"))
{
compiler = "ifcwin"; // Intel Fortran for Windows (known by cbFortran)
}
else
{
compiler = "icc";
}
} }
else if (compilerId == "Watcom" || compilerId == "OpenWatcom") else if (compilerId == "Watcom" || compilerId == "OpenWatcom")
{ {
compiler = "ow"; compiler = "ow";
} }
else if (compilerId == "Clang")
{
compiler = "clang";
}
else if (compilerId == "PGI")
{
if (pureFortran)
{
compiler = "pgifortran";
}
else
{
compiler = "pgi"; // does not exist as default in CodeBlocks 16.01
}
}
else if (compilerId == "GNU") else if (compilerId == "GNU")
{ {
compiler = "gcc"; if (pureFortran)
{
compiler = "gfortran";
}
else
{
compiler = "gcc";
}
} }
return compiler; return compiler;
} }