summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-10-09 14:21:28 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2013-10-09 14:21:28 (GMT)
commit12a7e2b10c447e3ed61c2bca69f0264f7fcbdef9 (patch)
treea54d4aee5c315f35281bd124fe9927da2cd50499 /Source
parent7f268c243f49775bb6de867ee49f3b48117c68ea (diff)
parent1763c31c3b964343b88f8f26dc2941dd8c0e1fbe (diff)
downloadCMake-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')
-rw-r--r--Source/cmDocumentVariables.cxx1
-rw-r--r--Source/cmGlobalGenerator.cxx41
-rw-r--r--Source/cmGlobalGenerator.h2
-rw-r--r--Source/cmPolicies.cxx17
-rw-r--r--Source/cmPolicies.h1
-rw-r--r--Source/kwsys/CMakeLists.txt3
6 files changed, 65 insertions, 0 deletions
diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx
index 8b5f851..58634ea 100644
--- a/Source/cmDocumentVariables.cxx
+++ b/Source/cmDocumentVariables.cxx
@@ -1622,6 +1622,7 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
"Possible values include:\n"
" Absoft = Absoft Fortran (absoft.com)\n"
" ADSP = Analog VisualDSP++ (analog.com)\n"
+ " AppleClang = Apple Clang (apple.com)\n"
" Clang = LLVM Clang (clang.llvm.org)\n"
" Cray = Cray Compiler (cray.com)\n"
" Embarcadero, Borland = Embarcadero (embarcadero.com)\n"
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)
{
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 18aba24..70f6e32 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -383,6 +383,8 @@ private:
void WriteSummary();
void WriteSummary(cmTarget* target);
+ void CheckCompilerIdCompatibility(cmMakefile* mf, std::string lang);
+
cmExternalMakefileProjectGenerator* ExtraGenerator;
// track files replaced during a Generate
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 9e5e6e0..1d3469f 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -620,6 +620,23 @@ cmPolicies::cmPolicies()
"The NEW behavior for this policy is to not to allow including the "
"result of an export() command.",
2,8,13,0, cmPolicies::WARN);
+
+ this->DefinePolicy(
+ CMP0025, "CMP0025",
+ "Compiler id for Apple Clang is now AppleClang.",
+ "CMake >= 2.8.13 recognize that Apple Clang is a different compiler "
+ "than upstream Clang and that they have different version numbers. "
+ "CMake now prefers to present this to projects by setting "
+ "CMAKE_<LANG>_COMPILER_ID to \"AppleClang\" instead of \"Clang\". "
+ "However, existing projects may assume the compiler id for Apple Clang "
+ "is just \"Clang\" as it was in CMake < 2.8.13. "
+ "Therefore this policy determines for Apple Clang which compiler id "
+ "to report in CMAKE_<LANG>_COMPILER_ID after <LANG> is enabled by "
+ "the project() or enable_language() command."
+ "\n"
+ "The OLD behavior for this policy is to use compiler id \"Clang\". "
+ "The NEW behavior for this policy is to use compiler id \"AppleClang\".",
+ 2,8,13,0, cmPolicies::WARN);
}
cmPolicies::~cmPolicies()
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index bafe5b2..ec8959d 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -75,6 +75,7 @@ public:
CMP0022, ///< INTERFACE_LINK_LIBRARIES defines the link interface
CMP0023, ///< Disallow mixing keyword and plain tll signatures
CMP0024, ///< Disallow including export() result.
+ CMP0025, ///< Compiler id for Apple Clang is now AppleClang
/** \brief Always the last entry.
*
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index 0f27836..a9d89d4 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -85,6 +85,9 @@
# written.
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR)
+IF(POLICY CMP0025)
+ CMAKE_POLICY(SET CMP0025 NEW)
+ENDIF()
#-----------------------------------------------------------------------------
# If a namespace is not specified, use "kwsys" and enable testing.