diff options
author | Brad King <brad.king@kitware.com> | 2013-10-09 14:21:28 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2013-10-09 14:21:28 (GMT) |
commit | 12a7e2b10c447e3ed61c2bca69f0264f7fcbdef9 (patch) | |
tree | a54d4aee5c315f35281bd124fe9927da2cd50499 /Source/cmGlobalGenerator.cxx | |
parent | 7f268c243f49775bb6de867ee49f3b48117c68ea (diff) | |
parent | 1763c31c3b964343b88f8f26dc2941dd8c0e1fbe (diff) | |
download | CMake-12a7e2b10c447e3ed61c2bca69f0264f7fcbdef9.zip CMake-12a7e2b10c447e3ed61c2bca69f0264f7fcbdef9.tar.gz CMake-12a7e2b10c447e3ed61c2bca69f0264f7fcbdef9.tar.bz2 |
Merge topic 'apple-clang-id'
1763c31 Set policy CMP0025 to NEW while building CMake itself
aa53ee5 Add policy CMP0025 for Apple Clang compiler id compatibility
ab65862 Clang: Add separate "AppleClang" compiler id
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index dc4bf50..eacf85b 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -624,6 +624,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 @@ -640,6 +643,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) { |