summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-10-02 13:52:48 -0400
committerBrad King <brad.king@kitware.com>2013-10-07 20:12:46 -0400
commitab65862417adc80dfb18170a6bd70889a24fe045 (patch)
tree52c103ea2e6bf812ce4ae883c0baf68bead8a1ba
parent904ff9fe592882db5dae88e526db2b380d92f87d (diff)
downloadcmake-ab65862417adc80dfb18170a6bd70889a24fe045.tar.gz
Clang: Add separate "AppleClang" compiler id
Apple distributes their own Clang build with their own version numbers that differ from upstream Clang. Use the __apple_build_version__ symbol to identify the Apple Clang compiler and report the Apple Build Version as the fourth version component in CMAKE_<LANG>_COMPILER_VERSION. Add Compiler/AppleClang-<lang> and Platform/Darwin-AppleClang-<lang> modules that simply include the upstream equivalents. Fix comparisons of CMAKE_<LANG>_COMPILER_ID to Clang in CMake's own source and tests to account for AppleClang.
-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--Tests/Assembler/CMakeLists.txt2
-rw-r--r--Tests/IncludeDirectories/CMakeLists.txt2
-rw-r--r--Utilities/cmlibarchive/CMakeLists.txt2
11 files changed, 21 insertions, 5 deletions
diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in
index 66a5582650..56c11a0bbd 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 5e87715c03..2b8bf6e2a1 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 0000000000..f52bde05eb
--- /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 0000000000..44070b83fe
--- /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 0000000000..680f7208e4
--- /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 0000000000..98971bbca3
--- /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 0000000000..4e9e7c12e7
--- /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 c4f6216b6c..a2a1bd683d 100644
--- a/Source/cmDocumentVariables.cxx
+++ b/Source/cmDocumentVariables.cxx
@@ -1606,6 +1606,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/Tests/Assembler/CMakeLists.txt b/Tests/Assembler/CMakeLists.txt
index bb4bcccbe8..1f07dc9cf4 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 35ad8dc90d..9ee195714c 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/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt
index 8ef0e89d6d..132bfebdb3 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")