summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGenerator.cxx
diff options
context:
space:
mode:
authormakise-homura <akemi_homura@kurisa.ch>2021-10-19 18:43:45 (GMT)
committermakise-homura <akemi_homura@kurisa.ch>2021-10-21 14:24:22 (GMT)
commit3958ed878f2365fd1af004341d45dac7f4e94afb (patch)
tree0192b68ccf8fc248efadb1bf91deddc1927bf434 /Source/cmGlobalGenerator.cxx
parent52ea22ca65d86627e9ab571f2a87d4a952a7d85e (diff)
downloadCMake-3958ed878f2365fd1af004341d45dac7f4e94afb.zip
CMake-3958ed878f2365fd1af004341d45dac7f4e94afb.tar.gz
CMake-3958ed878f2365fd1af004341d45dac7f4e94afb.tar.bz2
LCC: Add policy CMP0129 regarding interpreting LCC as GNU
Due to MCST LCC compiler identification is now changed to LCC, there should be a way for old projects to still identify it as GNU, as it was before. This commits adds the policy: CMP0129: Compiler id for MCST LCC compilers is now LCC, not GNU. This policy controls such a behavior. OLD behaivior is to treat LCC as GNU, NEW is to treat is as LCC.
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r--Source/cmGlobalGenerator.cxx48
1 files changed, 48 insertions, 0 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 6dabf63..d5207d8 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1038,6 +1038,54 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(
break;
}
}
+
+ if (compilerId == "LCC") {
+ switch (mf->GetPolicyStatus(cmPolicies::CMP0129)) {
+ case cmPolicies::WARN:
+ if (!this->CMakeInstance->GetIsInTryCompile() &&
+ mf->PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0129")) {
+ std::ostringstream w;
+ /* clang-format off */
+ w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0129) << "\n"
+ "Converting " << lang <<
+ R"( compiler id "LCC" to "GNU" for compatibility.)"
+ ;
+ /* clang-format on */
+ mf->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
+ }
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ // OLD behavior is to convert LCC to GNU.
+ mf->AddDefinition(compilerIdVar, "GNU");
+ if (lang == "C") {
+ mf->AddDefinition("CMAKE_COMPILER_IS_GNUCC", "1");
+ } else if (lang == "CXX") {
+ mf->AddDefinition("CMAKE_COMPILER_IS_GNUCXX", "1");
+ } else if (lang == "Fortran") {
+ mf->AddDefinition("CMAKE_COMPILER_IS_GNUG77", "1");
+ }
+ {
+ // Fix compiler versions.
+ std::string version = "CMAKE_" + lang + "_COMPILER_VERSION";
+ std::string emulated = "CMAKE_" + lang + "_SIMULATE_VERSION";
+ std::string emulatedId = "CMAKE_" + lang + "_SIMULATE_ID";
+ std::string const& actual = mf->GetRequiredDefinition(emulated);
+ mf->AddDefinition(version, actual);
+ mf->RemoveDefinition(emulatedId);
+ mf->RemoveDefinition(emulated);
+ }
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0129));
+ CM_FALLTHROUGH;
+ case cmPolicies::NEW:
+ // NEW behavior is to keep LCC.
+ break;
+ }
+ }
}
std::string cmGlobalGenerator::GetLanguageOutputExtension(