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.
This commit is contained in:
parent
904ff9fe59
commit
ab65862417
|
@ -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__)
|
||||||
|
|
|
@ -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__)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
include(Compiler/Clang-ASM)
|
|
@ -0,0 +1 @@
|
||||||
|
include(Compiler/Clang-C)
|
|
@ -0,0 +1 @@
|
||||||
|
include(Compiler/Clang-CXX)
|
|
@ -0,0 +1 @@
|
||||||
|
include(Platform/Darwin-Clang-C)
|
|
@ -0,0 +1 @@
|
||||||
|
include(Platform/Darwin-Clang-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"
|
||||||
|
|
|
@ -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};")
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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")
|
||||||
|
|
Loading…
Reference in New Issue