Explorar o código

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.
Brad King %!s(int64=12) %!d(string=hai) anos
pai
achega
ab65862417

+ 6 - 1
Modules/CMakeCCompilerId.c.in

@@ -29,7 +29,12 @@
 # endif
 # endif
 
 
 #elif defined(__clang__)
 #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_MAJOR DEC(__clang_major__)
 # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
 # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
 # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
 # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)

+ 6 - 1
Modules/CMakeCXXCompilerId.cpp.in

@@ -34,7 +34,12 @@
 # endif
 # endif
 
 
 #elif defined(__clang__)
 #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_MAJOR DEC(__clang_major__)
 # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
 # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
 # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
 # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)

+ 1 - 0
Modules/Compiler/AppleClang-ASM.cmake

@@ -0,0 +1 @@
+include(Compiler/Clang-ASM)

+ 1 - 0
Modules/Compiler/AppleClang-C.cmake

@@ -0,0 +1 @@
+include(Compiler/Clang-C)

+ 1 - 0
Modules/Compiler/AppleClang-CXX.cmake

@@ -0,0 +1 @@
+include(Compiler/Clang-CXX)

+ 1 - 0
Modules/Platform/Darwin-AppleClang-C.cmake

@@ -0,0 +1 @@
+include(Platform/Darwin-Clang-C)

+ 1 - 0
Modules/Platform/Darwin-AppleClang-CXX.cmake

@@ -0,0 +1 @@
+include(Platform/Darwin-Clang-CXX)

+ 1 - 0
Source/cmDocumentVariables.cxx

@@ -1606,6 +1606,7 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
      "Possible values include:\n"
      "Possible values include:\n"
      "  Absoft = Absoft Fortran (absoft.com)\n"
      "  Absoft = Absoft Fortran (absoft.com)\n"
      "  ADSP = Analog VisualDSP++ (analog.com)\n"
      "  ADSP = Analog VisualDSP++ (analog.com)\n"
+     "  AppleClang = Apple Clang (apple.com)\n"
      "  Clang = LLVM Clang (clang.llvm.org)\n"
      "  Clang = LLVM Clang (clang.llvm.org)\n"
      "  Cray = Cray Compiler (cray.com)\n"
      "  Cray = Cray Compiler (cray.com)\n"
      "  Embarcadero, Borland = Embarcadero (embarcadero.com)\n"
      "  Embarcadero, Borland = Embarcadero (embarcadero.com)\n"

+ 1 - 1
Tests/Assembler/CMakeLists.txt

@@ -9,7 +9,7 @@ set(SRCS)
 # and also generate assembler files from C:
 # and also generate assembler files from C:
 if("${CMAKE_GENERATOR}" MATCHES "Makefile|Xcode" AND
 if("${CMAKE_GENERATOR}" MATCHES "Makefile|Xcode" AND
     NOT CMAKE_OSX_ARCHITECTURES)
     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}")
     set(C_FLAGS "${CMAKE_C_FLAGS}")
     separate_arguments(C_FLAGS)
     separate_arguments(C_FLAGS)
     if(CMAKE_OSX_SYSROOT AND CMAKE_C_SYSROOT_FLAG AND NOT ";${C_FLAGS};" MATCHES ";${CMAKE_C_SYSROOT_FLAG};")
     if(CMAKE_OSX_SYSROOT AND CMAKE_C_SYSROOT_FLAG AND NOT ";${C_FLAGS};" MATCHES ";${CMAKE_C_SYSROOT_FLAG};")

+ 1 - 1
Tests/IncludeDirectories/CMakeLists.txt

@@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.6)
 project(IncludeDirectories)
 project(IncludeDirectories)
 
 
 if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4)
 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"))
     AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja"))
   include(CheckCXXCompilerFlag)
   include(CheckCXXCompilerFlag)
   check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test)
   check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test)

+ 1 - 1
Utilities/cmlibarchive/CMakeLists.txt

@@ -56,7 +56,7 @@ SET(CMAKE_REQUIRED_FLAGS)
 
 
 # Disable warnings to avoid changing 3rd party code.
 # Disable warnings to avoid changing 3rd party code.
 IF("${CMAKE_C_COMPILER_ID}" MATCHES
 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")
   SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
 ELSEIF("${CMAKE_C_COMPILER_ID}" MATCHES "^(PathScale)$")
 ELSEIF("${CMAKE_C_COMPILER_ID}" MATCHES "^(PathScale)$")
   SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall")
   SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall")