Translate the cmake compiler id into the CodeBlocks compiler id
| 626 | |
| 627 | // Translate the cmake compiler id into the CodeBlocks compiler id |
| 628 | std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(cmMakefile const* mf) |
| 629 | { |
| 630 | // allow the user to overwrite the detected compiler |
| 631 | std::string userCompiler = |
| 632 | mf->GetSafeDefinition("CMAKE_CODEBLOCKS_COMPILER_ID"); |
| 633 | if (!userCompiler.empty()) { |
| 634 | return userCompiler; |
| 635 | } |
| 636 | |
| 637 | // figure out which language to use |
| 638 | // for now care only for C, C++, and Fortran |
| 639 | |
| 640 | // projects with C/C++ and Fortran are handled as C/C++ projects |
| 641 | bool pureFortran = false; |
| 642 | std::string compilerIdVar; |
| 643 | if (this->GlobalGenerator->GetLanguageEnabled("CXX")) { |
| 644 | compilerIdVar = "CMAKE_CXX_COMPILER_ID"; |
| 645 | } else if (this->GlobalGenerator->GetLanguageEnabled("C")) { |
| 646 | compilerIdVar = "CMAKE_C_COMPILER_ID"; |
| 647 | } else if (this->GlobalGenerator->GetLanguageEnabled("Fortran")) { |
| 648 | compilerIdVar = "CMAKE_Fortran_COMPILER_ID"; |
| 649 | pureFortran = true; |
| 650 | } |
| 651 | |
| 652 | std::string const& compilerId = mf->GetSafeDefinition(compilerIdVar); |
| 653 | std::string compiler = "gcc"; // default to gcc |
| 654 | if (compilerId == "MSVC") { |
| 655 | if (mf->IsDefinitionSet("MSVC10")) { |
| 656 | compiler = "msvc10"; |
| 657 | } else { |
| 658 | compiler = "msvc8"; |
| 659 | } |
| 660 | } else if (compilerId == "Borland") { |
| 661 | compiler = "bcc"; |
| 662 | } else if (compilerId == "SDCC") { |
| 663 | compiler = "sdcc"; |
| 664 | } else if (compilerId == "Intel") { |
| 665 | if (pureFortran && mf->IsDefinitionSet("WIN32")) { |
| 666 | compiler = "ifcwin"; // Intel Fortran for Windows (known by cbFortran) |
| 667 | } else { |
| 668 | compiler = "icc"; |
| 669 | } |
| 670 | } else if (compilerId == "Watcom" || compilerId == "OpenWatcom") { |
| 671 | compiler = "ow"; |
| 672 | } else if (compilerId == "Clang") { |
| 673 | compiler = "clang"; |
| 674 | } else if (compilerId == "PGI") { |
| 675 | if (pureFortran) { |
| 676 | compiler = "pgifortran"; |
| 677 | } else { |
| 678 | compiler = "pgi"; // does not exist as default in CodeBlocks 16.01 |
| 679 | } |
| 680 | } else if (compilerId == "LCC") { |
| 681 | if (pureFortran) { |
| 682 | compiler = "lfortran"; |
| 683 | } else { |
| 684 | compiler = "lcc"; |
| 685 | } |
no test coverage detected