diff options
author | Brad King <brad.king@kitware.com> | 2013-10-02 17:52:48 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-10-08 00:12:46 (GMT) |
commit | ab65862417adc80dfb18170a6bd70889a24fe045 (patch) | |
tree | 52c103ea2e6bf812ce4ae883c0baf68bead8a1ba | |
parent | 904ff9fe592882db5dae88e526db2b380d92f87d (diff) | |
download | CMake-ab65862417adc80dfb18170a6bd70889a24fe045.zip CMake-ab65862417adc80dfb18170a6bd70889a24fe045.tar.gz CMake-ab65862417adc80dfb18170a6bd70889a24fe045.tar.bz2 |
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.in | 7 | ||||
-rw-r--r-- | Modules/CMakeCXXCompilerId.cpp.in | 7 | ||||
-rw-r--r-- | Modules/Compiler/AppleClang-ASM.cmake | 1 | ||||
-rw-r--r-- | Modules/Compiler/AppleClang-C.cmake | 1 | ||||
-rw-r--r-- | Modules/Compiler/AppleClang-CXX.cmake | 1 | ||||
-rw-r--r-- | Modules/Platform/Darwin-AppleClang-C.cmake | 1 | ||||
-rw-r--r-- | Modules/Platform/Darwin-AppleClang-CXX.cmake | 1 | ||||
-rw-r--r-- | Source/cmDocumentVariables.cxx | 1 | ||||
-rw-r--r-- | Tests/Assembler/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/IncludeDirectories/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Utilities/cmlibarchive/CMakeLists.txt | 2 |
11 files changed, 21 insertions, 5 deletions
diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index 66a5582..56c11a0 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 5e87715..2b8bf6e 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 c4f6216..a2a1bd6 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 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/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") |