| 974 | } |
| 975 | |
| 976 | void cmGlobalFastbuildGenerator::AddCompiler(std::string const& language, |
| 977 | cmMakefile* mf) |
| 978 | { |
| 979 | if (this->Compilers.find(FASTBUILD_COMPILER_PREFIX + language) != |
| 980 | this->Compilers.end()) { |
| 981 | return; |
| 982 | } |
| 983 | |
| 984 | // Calculate the root location of the compiler |
| 985 | std::string const variableString = cmStrCat("CMAKE_", language, "_COMPILER"); |
| 986 | std::string const compilerLocation = mf->GetSafeDefinition(variableString); |
| 987 | if (compilerLocation.empty()) { |
| 988 | return; |
| 989 | } |
| 990 | |
| 991 | // Add the language to the compiler's name |
| 992 | FastbuildCompiler compilerDef; |
| 993 | compilerDef.ExtraVariables["Root"] = |
| 994 | cmSystemTools::GetFilenamePath(compilerLocation); |
| 995 | compilerDef.Name = FASTBUILD_COMPILER_PREFIX + language; |
| 996 | compilerDef.Executable = compilerLocation; |
| 997 | compilerDef.CmakeCompilerID = |
| 998 | mf->GetSafeDefinition(cmStrCat("CMAKE_", language, "_COMPILER_ID")); |
| 999 | if (compilerDef.CmakeCompilerID == "Clang" && |
| 1000 | mf->GetSafeDefinition(cmStrCat( |
| 1001 | "CMAKE_", language, "_COMPILER_FRONTEND_VARIANT")) == "MSVC") { |
| 1002 | compilerDef.CmakeCompilerID = "Clang-cl"; |
| 1003 | } |
| 1004 | |
| 1005 | compilerDef.CmakeCompilerVersion = |
| 1006 | mf->GetSafeDefinition(cmStrCat("CMAKE_", language, "_COMPILER_VERSION")); |
| 1007 | compilerDef.Language = language; |
| 1008 | |
| 1009 | cmExpandList(mf->GetSafeDefinition(FASTBUILD_COMPILER_EXTRA_FILES), |
| 1010 | compilerDef.ExtraFiles); |
| 1011 | |
| 1012 | if (supportedLanguages.find(language) != supportedLanguages.end()) { |
| 1013 | auto const iter = |
| 1014 | compilerIdToFastbuildFamily.find(compilerDef.CmakeCompilerID); |
| 1015 | if (iter != compilerIdToFastbuildFamily.end()) { |
| 1016 | compilerDef.CompilerFamily = iter->second; |
| 1017 | } |
| 1018 | } |
| 1019 | |
| 1020 | // Has to be called after we determined 'CompilerFamily'. |
| 1021 | ReadCompilerOptions(compilerDef, mf); |
| 1022 | |
| 1023 | // If FASTBUILD_COMPILER_EXTRA_FILES is not set - automatically add extra |
| 1024 | // files based on compiler (see |
| 1025 | // https://fastbuild.org/docs/functions/compiler.html) |
| 1026 | if (!this->GetCMakeInstance()->GetIsInTryCompile() && |
| 1027 | compilerDef.ExtraFiles.empty() && |
| 1028 | (language == "C" || language == "CXX") && |
| 1029 | compilerDef.CmakeCompilerID == "MSVC") { |
| 1030 | // https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html |
| 1031 | |
| 1032 | // Calculate the i18n number. |
| 1033 | std::string const i18nNum = |
no test coverage detected