MCPcopy Create free account
hub / github.com/Kitware/CMake / GetCBCompilerId

Method GetCBCompilerId

Source/cmExtraCodeBlocksGenerator.cxx:628–694  ·  view source on GitHub ↗

Translate the cmake compiler id into the CodeBlocks compiler id

Source from the content-addressed store, hash-verified

626
627// Translate the cmake compiler id into the CodeBlocks compiler id
628std::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 }

Callers 1

CreateNewProjectFileMethod · 0.95

Calls 3

IsDefinitionSetMethod · 0.80
emptyMethod · 0.45
GetLanguageEnabledMethod · 0.45

Tested by

no test coverage detected