summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--CMakeLists.txt3
-rw-r--r--Modules/CMakeCCompilerId.c.in7
-rw-r--r--Modules/CMakeCXXCompilerId.cpp.in7
-rw-r--r--Modules/Compiler/AppleClang-ASM.cmake1
-rw-r--r--Modules/Compiler/AppleClang-C.cmake1
-rw-r--r--Modules/Compiler/AppleClang-CXX.cmake1
-rw-r--r--Modules/Platform/Darwin-AppleClang-C.cmake1
-rw-r--r--Modules/Platform/Darwin-AppleClang-CXX.cmake1
-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
-rw-r--r--Tests/Assembler/CMakeLists.txt2
-rw-r--r--Tests/IncludeDirectories/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/RunCMake.cmake3
-rw-r--r--Utilities/cmcurl/CMakeLists.txt3
-rw-r--r--Utilities/cmlibarchive/CMakeLists.txt2
19 files changed, 94 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1fbbe08..77b4604 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,6 +11,9 @@
#=============================================================================
cmake_minimum_required(VERSION 2.8.2 FATAL_ERROR)
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
+if(POLICY CMP0025)
+ cmake_policy(SET CMP0025 NEW)
+endif()
project(CMake)
if(CMAKE_BOOTSTRAP)
diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in
index dda7bf6..6dde1c3 100644
--- a/Modules/CMakeCCompilerId.c.in
+++ b/Modules/CMakeCCompilerId.c.in
@@ -29,7 +29,12 @@
# endif
#elif defined(__clang__)
-# define COMPILER_ID "Clang"
+# if defined(__apple_build_version__)
+# define COMPILER_ID "AppleClang"
+# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
+# else
+# define COMPILER_ID "Clang"
+# endif
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in
index 915ae7f..3a60922 100644
--- a/Modules/CMakeCXXCompilerId.cpp.in
+++ b/Modules/CMakeCXXCompilerId.cpp.in
@@ -34,7 +34,12 @@
# endif
#elif defined(__clang__)
-# define COMPILER_ID "Clang"
+# if defined(__apple_build_version__)
+# define COMPILER_ID "AppleClang"
+# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
+# else
+# define COMPILER_ID "Clang"
+# endif
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
diff --git a/Modules/Compiler/AppleClang-ASM.cmake b/Modules/Compiler/AppleClang-ASM.cmake
new file mode 100644
index 0000000..f52bde0
--- /dev/null
+++ b/Modules/Compiler/AppleClang-ASM.cmake
@@ -0,0 +1 @@
+include(Compiler/Clang-ASM)
diff --git a/Modules/Compiler/AppleClang-C.cmake b/Modules/Compiler/AppleClang-C.cmake
new file mode 100644
index 0000000..44070b8
--- /dev/null
+++ b/Modules/Compiler/AppleClang-C.cmake
@@ -0,0 +1 @@
+include(Compiler/Clang-C)
diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake
new file mode 100644
index 0000000..680f720
--- /dev/null
+++ b/Modules/Compiler/AppleClang-CXX.cmake
@@ -0,0 +1 @@
+include(Compiler/Clang-CXX)
diff --git a/Modules/Platform/Darwin-AppleClang-C.cmake b/Modules/Platform/Darwin-AppleClang-C.cmake
new file mode 100644
index 0000000..98971bb
--- /dev/null
+++ b/Modules/Platform/Darwin-AppleClang-C.cmake
@@ -0,0 +1 @@
+include(Platform/Darwin-Clang-C)
diff --git a/Modules/Platform/Darwin-AppleClang-CXX.cmake b/Modules/Platform/Darwin-AppleClang-CXX.cmake
new file mode 100644
index 0000000..4e9e7c1
--- /dev/null
+++ b/Modules/Platform/Darwin-AppleClang-CXX.cmake
@@ -0,0 +1 @@
+include(Platform/Darwin-Clang-CXX)
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.
diff --git a/Tests/Assembler/CMakeLists.txt b/Tests/Assembler/CMakeLists.txt
index bb4bccc..1f07dc9 100644
--- a/Tests/Assembler/CMakeLists.txt
+++ b/Tests/Assembler/CMakeLists.txt
@@ -9,7 +9,7 @@ set(SRCS)
# and also generate assembler files from C:
if("${CMAKE_GENERATOR}" MATCHES "Makefile|Xcode" AND
NOT CMAKE_OSX_ARCHITECTURES)
- if(("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|Clang|HP|SunPro|XL)$") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel" AND UNIX))
+ if(("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|Clang|AppleClang|HP|SunPro|XL)$") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel" AND UNIX))
set(C_FLAGS "${CMAKE_C_FLAGS}")
separate_arguments(C_FLAGS)
if(CMAKE_OSX_SYSROOT AND CMAKE_C_SYSROOT_FLAG AND NOT ";${C_FLAGS};" MATCHES ";${CMAKE_C_SYSROOT_FLAG};")
diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt
index 35ad8dc..9ee1957 100644
--- a/Tests/IncludeDirectories/CMakeLists.txt
+++ b/Tests/IncludeDirectories/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.6)
project(IncludeDirectories)
if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4)
- OR CMAKE_C_COMPILER_ID STREQUAL Clang)
+ OR CMAKE_C_COMPILER_ID STREQUAL Clang OR CMAKE_C_COMPILER_ID STREQUAL AppleClang)
AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja"))
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test)
diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake
index f770c93..5c7c05c 100644
--- a/Tests/RunCMake/RunCMake.cmake
+++ b/Tests/RunCMake/RunCMake.cmake
@@ -36,6 +36,9 @@ function(run_cmake test)
if(NOT DEFINED RunCMake_TEST_OPTIONS)
set(RunCMake_TEST_OPTIONS "")
endif()
+ if(APPLE)
+ list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0025=NEW)
+ endif()
execute_process(
COMMAND ${CMAKE_COMMAND} "${RunCMake_TEST_SOURCE_DIR}"
-G "${RunCMake_GENERATOR}"
diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt
index 74a713d..abf04d8 100644
--- a/Utilities/cmcurl/CMakeLists.txt
+++ b/Utilities/cmcurl/CMakeLists.txt
@@ -1,4 +1,7 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR)
+IF(POLICY CMP0025)
+ CMAKE_POLICY(SET CMP0025 NEW)
+ENDIF()
PROJECT(LIBCURL C)
# Setup package meta-data
diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt
index 8ef0e89..132bfeb 100644
--- a/Utilities/cmlibarchive/CMakeLists.txt
+++ b/Utilities/cmlibarchive/CMakeLists.txt
@@ -56,7 +56,7 @@ SET(CMAKE_REQUIRED_FLAGS)
# Disable warnings to avoid changing 3rd party code.
IF("${CMAKE_C_COMPILER_ID}" MATCHES
- "^(GNU|Clang|XL|VisualAge|SunPro|MIPSpro|HP|Intel)$")
+ "^(GNU|Clang|AppleClang|XL|VisualAge|SunPro|MIPSpro|HP|Intel)$")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
ELSEIF("${CMAKE_C_COMPILER_ID}" MATCHES "^(PathScale)$")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall")