summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorRaul Tambre <raul@tambre.ee>2021-02-13 10:21:52 +0200
committerRaul Tambre <raul@tambre.ee>2021-02-25 18:22:10 +0200
commit356e83c156a37d5882685da11aa8d5be057cad33 (patch)
tree2ed086f27a59683f22168c55b1d519af0f563792 /Modules
parentf112450ea0d5d1784e24f6b4aae4212700f566c1 (diff)
downloadcmake-356e83c156a37d5882685da11aa8d5be057cad33.tar.gz
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')
-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 e905909675..220e009bb0 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")