diff options
author | Brad King <brad.king@kitware.com> | 2021-10-22 11:08:47 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-10-22 11:08:58 (GMT) |
commit | ca3e83250f43285fa3c9a0f5e062a3fd94a097e0 (patch) | |
tree | 8a226aa6cd42cab4944c4c0861e1b6b0419cfd83 /Source/cmGlobalGenerator.cxx | |
parent | b3802804f1a7fa5c994fdefe34f2e94138759d8d (diff) | |
parent | 3958ed878f2365fd1af004341d45dac7f4e94afb (diff) | |
download | CMake-ca3e83250f43285fa3c9a0f5e062a3fd94a097e0.zip CMake-ca3e83250f43285fa3c9a0f5e062a3fd94a097e0.tar.gz CMake-ca3e83250f43285fa3c9a0f5e062a3fd94a097e0.tar.bz2 |
Merge topic 'lcc-policy'
3958ed878f LCC: Add policy CMP0129 regarding interpreting LCC as GNU
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !6643
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index ac283ab..8799180 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1027,6 +1027,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( |