summaryrefslogtreecommitdiffstats
path: root/Modules/Compiler
diff options
context:
space:
mode:
authorRaul Tambre <raul@tambre.ee>2021-02-13 08:21:52 (GMT)
committerRaul Tambre <raul@tambre.ee>2021-02-25 16:22:10 (GMT)
commit356e83c156a37d5882685da11aa8d5be057cad33 (patch)
tree2ed086f27a59683f22168c55b1d519af0f563792 /Modules/Compiler
parentf112450ea0d5d1784e24f6b4aae4212700f566c1 (diff)
downloadCMake-356e83c156a37d5882685da11aa8d5be057cad33.zip
CMake-356e83c156a37d5882685da11aa8d5be057cad33.tar.gz
CMake-356e83c156a37d5882685da11aa8d5be057cad33.tar.bz2
Clang: Correct C standards flags for ancient versions
C89, C99 flags in LLVM commit ff43821d5380ee38aff421701f1d461242b524ee. C90 flag in LLVM commit 229ce60fc9983df5f7e83e25fa6b5c0ca4d2b135. C1x flag in LLVM commit a686b5f8bf7b5a2ab636c0c2de5ad4c174aa33e0. C11 flag in LLVM commit 6784aeb9ef96e5735850fa7226ed0cb45cb82e75. Mark C90, C99 full support since 2.1. Might've been possibly a little later, but source spelunking that much back is difficult. Mark C11 full support since 3.0, which added _Static_assert in LLVM commit 3d9cbdc3e66e274d5d3cb94ce81a65478d9baae0.
Diffstat (limited to 'Modules/Compiler')
-rw-r--r--Modules/Compiler/Clang-C.cmake37
1 files changed, 22 insertions, 15 deletions
diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake
index e905909..220e009 100644
--- a/Modules/Compiler/Clang-C.cmake
+++ b/Modules/Compiler/Clang-C.cmake
@@ -25,31 +25,38 @@ elseif("x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
endif()
endif()
-if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4)
- set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
- set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
- set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
-
- if(NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
+if(NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
+ if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 2.1)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90")
set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99")
set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99")
+ endif()
+ if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 3.1)
set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
- else()
- # clang-cl doesn't have any of these
- set(CMAKE_C90_STANDARD_COMPILE_OPTION "")
- set(CMAKE_C90_EXTENSION_COMPILE_OPTION "")
+ elseif(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 3.0)
+ set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c1x")
+ set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu1x")
+ endif()
+else()
+ set(CMAKE_C90_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_C90_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_C99_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_C99_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_C11_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_C11_EXTENSION_COMPILE_OPTION "")
+endif()
- set(CMAKE_C99_STANDARD_COMPILE_OPTION "")
- set(CMAKE_C99_EXTENSION_COMPILE_OPTION "")
+if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 2.1)
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
+ set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
+endif()
- set(CMAKE_C11_STANDARD_COMPILE_OPTION "")
- set(CMAKE_C11_EXTENSION_COMPILE_OPTION "")
- endif()
+if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 3.0)
+ set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
endif()
if(NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")