diff options
author | Brad King <brad.king@kitware.com> | 2019-02-21 18:37:48 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-02-25 13:24:28 (GMT) |
commit | 5c41386357977d931f73e3bb824080af795b3cd5 (patch) | |
tree | 45ecef4703540ce639600c28464e5c7313526c0f /Source/cmGlobalGenerator.cxx | |
parent | 82782379337fe922f96f4f19b8deae1fab6212fe (diff) | |
download | CMake-5c41386357977d931f73e3bb824080af795b3cd5.zip CMake-5c41386357977d931f73e3bb824080af795b3cd5.tar.gz CMake-5c41386357977d931f73e3bb824080af795b3cd5.tar.bz2 |
XLClang: Add policy CMP0089 to present as XL for compatibility
We now identify IBM's Clang-based XL compilers, which define
`__ibmxl__`, as `XLClang` rather than `XL`. In order to support
existing project code that checks for `XL`, add a policy whose OLD
behavior is to present the compiler id as `XL` and whose NEW behavior is
to present the compiler id as `XLClang` as we really detect it.
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 8107a07..4d6ffab 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -956,6 +956,36 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility( break; } } + + if (strcmp(compilerId, "XLClang") == 0) { + switch (mf->GetPolicyStatus(cmPolicies::CMP0089)) { + case cmPolicies::WARN: + if (!this->CMakeInstance->GetIsInTryCompile() && + mf->PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0089")) { + std::ostringstream w; + /* clang-format off */ + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0089) << "\n" + "Converting " << lang << + " compiler id \"XLClang\" to \"XL\" for compatibility." + ; + /* clang-format on */ + mf->IssueMessage(MessageType::AUTHOR_WARNING, w.str()); + } + CM_FALLTHROUGH; + case cmPolicies::OLD: + // OLD behavior is to convert XLClang to XL. + mf->AddDefinition(compilerIdVar, "XL"); + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + mf->IssueMessage( + MessageType::FATAL_ERROR, + cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0089)); + case cmPolicies::NEW: + // NEW behavior is to keep AppleClang. + break; + } + } } std::string cmGlobalGenerator::GetLanguageOutputExtension( |