1include(Compiler/GNU) 2__compiler_gnu(C) 3 4 5if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) 6 AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" 7 AND CMAKE_DEPFILE_FLAGS_C) 8 # dependencies are computed by the compiler itself 9 set(CMAKE_C_DEPFILE_FORMAT gcc) 10 set(CMAKE_C_DEPENDS_USE_COMPILER TRUE) 11endif() 12 13set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c) 14 15if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5) 16 set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") 17 set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") 18elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) 19 set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89") 20 set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu89") 21endif() 22 23if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) 24 set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) 25 set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") 26 set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") 27 set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) 28endif() 29 30if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) 31 set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") 32 set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") 33 set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) 34elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) 35 set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c1x") 36 set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu1x") 37endif() 38 39if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1) 40 set(CMAKE_C17_STANDARD_COMPILE_OPTION "-std=c17") 41 set(CMAKE_C17_EXTENSION_COMPILE_OPTION "-std=gnu17") 42endif() 43 44if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 9.1) 45 set(CMAKE_C23_STANDARD_COMPILE_OPTION "-std=c2x") 46 set(CMAKE_C23_EXTENSION_COMPILE_OPTION "-std=gnu2x") 47endif() 48 49__compiler_check_default_language_standard(C 3.4 90 5.0 11 8.1 17) 50