summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-10-02 18:10:38 (GMT)
committerBrad King <brad.king@kitware.com>2013-10-08 00:12:46 (GMT)
commitaa53ee57bb50faa3aa64e86cb58bbe2df6688335 (patch)
tree82d4a635097a71c9248f6251e02c67e0db0194f4 /Source/cmGlobalGenerator.cxx
parentab65862417adc80dfb18170a6bd70889a24fe045 (diff)
downloadCMake-aa53ee57bb50faa3aa64e86cb58bbe2df6688335.zip
CMake-aa53ee57bb50faa3aa64e86cb58bbe2df6688335.tar.gz
CMake-aa53ee57bb50faa3aa64e86cb58bbe2df6688335.tar.bz2
Add policy CMP0025 for Apple Clang compiler id compatibility
The parent commit introduced a separate "AppleClang" compiler id for Apple's Clang distribution. Add a policy in order to support projects that expect this compiler's id to be just "Clang". When the policy is OLD or not set, map AppleClang back to Clang. Continue to use the AppleClang id internally while enabling the language, but set the CMAKE_<LANG>_COMPILER_ID after project() or enable_language() to the compatible value for use by project code.
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r--Source/cmGlobalGenerator.cxx41
1 files changed, 41 insertions, 0 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 7f2b592..2c3834a 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -616,6 +616,9 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
{
this->LanguageToOriginalSharedLibFlags[lang] = sharedLibFlags;
}
+
+ // Translate compiler ids for compatibility.
+ this->CheckCompilerIdCompatibility(mf, lang);
} // end for each language
// Now load files that can override any settings on the platform or for
@@ -632,6 +635,44 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
}
//----------------------------------------------------------------------------
+void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
+ std::string lang)
+{
+ std::string compilerIdVar = "CMAKE_" + lang + "_COMPILER_ID";
+ const char* compilerId = mf->GetDefinition(compilerIdVar.c_str());
+ if(compilerId && strcmp(compilerId, "AppleClang") == 0)
+ {
+ cmPolicies* policies = this->CMakeInstance->GetPolicies();
+ switch(mf->GetPolicyStatus(cmPolicies::CMP0025))
+ {
+ case cmPolicies::WARN:
+ if(!this->CMakeInstance->GetIsInTryCompile())
+ {
+ cmOStringStream w;
+ w << policies->GetPolicyWarning(cmPolicies::CMP0025) << "\n"
+ "Converting " << lang <<
+ " compiler id \"AppleClang\" to \"Clang\" for compatibility."
+ ;
+ mf->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ }
+ case cmPolicies::OLD:
+ // OLD behavior is to convert AppleClang to Clang.
+ mf->AddDefinition(compilerIdVar.c_str(), "Clang");
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ mf->IssueMessage(
+ cmake::FATAL_ERROR,
+ policies->GetRequiredPolicyError(cmPolicies::CMP0025)
+ );
+ case cmPolicies::NEW:
+ // NEW behavior is to keep AppleClang.
+ break;
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
const char*
cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source)
{