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

Method CheckCompilerIdCompatibility

Source/cmGlobalGenerator.cxx:1010–1082  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1008}
1009
1010void cmGlobalGenerator::CheckCompilerIdCompatibility(
1011 cmMakefile* mf, std::string const& lang) const
1012{
1013 std::string compilerIdVar = cmStrCat("CMAKE_", lang, "_COMPILER_ID");
1014 std::string const compilerId = mf->GetSafeDefinition(compilerIdVar);
1015
1016 if (compilerId == "XLClang") {
1017 switch (mf->GetPolicyStatus(cmPolicies::CMP0089)) {
1018 case cmPolicies::WARN:
1019 if (!this->CMakeInstance->GetIsInTryCompile() &&
1020 mf->PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0089")) {
1021 std::ostringstream w;
1022 /* clang-format off */
1023 w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0089) << "\n"
1024 "Converting " << lang <<
1025 R"( compiler id "XLClang" to "XL" for compatibility.)"
1026 ;
1027 /* clang-format on */
1028 mf->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
1029 }
1030 CM_FALLTHROUGH;
1031 case cmPolicies::OLD:
1032 // OLD behavior is to convert XLClang to XL.
1033 mf->AddDefinition(compilerIdVar, "XL");
1034 break;
1035 case cmPolicies::NEW:
1036 // NEW behavior is to keep AppleClang.
1037 break;
1038 }
1039 }
1040
1041 if (compilerId == "LCC") {
1042 switch (mf->GetPolicyStatus(cmPolicies::CMP0129)) {
1043 case cmPolicies::WARN:
1044 if (!this->CMakeInstance->GetIsInTryCompile() &&
1045 mf->PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0129")) {
1046 std::ostringstream w;
1047 /* clang-format off */
1048 w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0129) << "\n"
1049 "Converting " << lang <<
1050 R"( compiler id "LCC" to "GNU" for compatibility.)"
1051 ;
1052 /* clang-format on */
1053 mf->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
1054 }
1055 CM_FALLTHROUGH;
1056 case cmPolicies::OLD:
1057 // OLD behavior is to convert LCC to GNU.
1058 mf->AddDefinition(compilerIdVar, "GNU");
1059 if (lang == "C") {
1060 mf->AddDefinition("CMAKE_COMPILER_IS_GNUCC", "1");
1061 } else if (lang == "CXX") {
1062 mf->AddDefinition("CMAKE_COMPILER_IS_GNUCXX", "1");
1063 } else if (lang == "Fortran") {
1064 mf->AddDefinition("CMAKE_COMPILER_IS_GNUG77", "1");
1065 }
1066 {
1067 // Fix compiler versions.

Callers 1

EnableLanguageMethod · 0.95

Calls 8

GetIsInTryCompileMethod · 0.80
strMethod · 0.80
cmStrCatFunction · 0.70
GetPolicyStatusMethod · 0.45
IssueMessageMethod · 0.45
AddDefinitionMethod · 0.45
RemoveDefinitionMethod · 0.45

Tested by

no test coverage detected