Commit 644d3b86 authored by Robert Maynard's avatar Robert Maynard

C: Compile when possible with explicit `C` language flag set

Issue: #14516, #20716
parent c08ee5e7
include(Compiler/Clang)
__compiler_clang(C)
set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c)
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90")
......
......@@ -8,6 +8,8 @@ endif()
if("x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC")
set(CMAKE_C_CLANG_TIDY_DRIVER_MODE "cl")
elseif("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c)
endif()
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4)
......
include(Compiler/GNU)
__compiler_gnu(C)
set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c)
if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90")
......
......@@ -28,6 +28,8 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
else()
set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c)
if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0)
set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
......
......@@ -6,6 +6,8 @@ string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG")
# -qthreaded = Ensures that all optimizations will be thread-safe
string(APPEND CMAKE_C_FLAGS_INIT " -qthreaded")
set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -qsourcetype=c)
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-qlanglvl=stdc89")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-qlanglvl=extc89")
......
include(Compiler/XLClang)
__compiler_xlclang(C)
set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c)
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu89")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment