Merge pull request #10705 from traceon/apple-clang-version-check-char8_t-fix

Blind fix for AppleClang version and char8_t support check
This commit is contained in:
alexey-milovidov 2020-05-06 19:20:30 +03:00 committed by GitHub
commit 69dcd80e15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,14 @@
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set (COMPILER_GCC 1)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
# It's very difficult to check what is the correspondence between clang and AppleClang versions.
# There are many complaints that some version of AppleClang does not work, but we are not able to dig into it.
message(FATAL_ERROR "AppleClang compiler is not supported. You have to use the latest clang version.")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0.1) # AppleClang 10.0.1 (Xcode 10.2) is the lowest version that corresponds to LLVM/Clang upstream version not older than 7.0.0.
message(FATAL_ERROR "AppleClang ${CMAKE_CXX_COMPILER_VERSION} compiler is not supported. Compiler version must be at least 10.0.1 (Xcode 10.2).")
elseif (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.0.0) # AppleClang 11.0.0 (Xcode 11.0) is the lowest version that corresponds to LLVM/Clang upstream version not older than 8.0.0.
# char8_t is available staring (upstream vanilla) Clang 7, but prior to Clang 8, it is not enabled by -std=c++20 and can be enabled with -fchar8_t.
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fchar8_t")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fchar8_t")
endif()
set (COMPILER_CLANG 1)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set (COMPILER_CLANG 1)
endif ()