mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-03 21:00:01 -05:00
Merge topic 'compile-features-C-language'
e0890d03 Features: Extend concept to C language.
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
|
||||
set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 407")
|
||||
|
||||
set(GNU46_C11 "${_cmake_oldestSupported} && __STDC_VERSION__ >= 201112L")
|
||||
set(_cmake_feature_test_c_static_assert "${GNU46_C11}")
|
||||
# Since 4.4 at least:
|
||||
set(GNU44_C99 "${_cmake_oldestSupported} && __STDC_VERSION__ >= 199901L")
|
||||
set(_cmake_feature_test_c_restrict "${GNU44_C99}")
|
||||
set(_cmake_feature_test_c_variadic_macros "${GNU44_C99}")
|
||||
|
||||
set(GNU_C90 "${_cmake_oldestSupported} && !defined(__STDC_VERSION__)")
|
||||
set(_cmake_feature_test_c_function_prototypes "${GNU_C90}")
|
||||
@@ -1,2 +1,34 @@
|
||||
include(Compiler/GNU)
|
||||
__compiler_gnu(C)
|
||||
|
||||
if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7)
|
||||
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")
|
||||
|
||||
set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
|
||||
set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
|
||||
endif()
|
||||
|
||||
# This may change in a future GNU version.
|
||||
set(CMAKE_C_STANDARD_DEFAULT 90)
|
||||
|
||||
macro(cmake_record_c_compile_features)
|
||||
macro(_get_gcc_features std_version list)
|
||||
record_compiler_features(C "-std=${std_version}" ${list})
|
||||
endmacro()
|
||||
|
||||
if (UNIX AND NOT APPLE AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7)
|
||||
_get_gcc_features(c90 CMAKE_C90_COMPILE_FEATURES)
|
||||
if (_result EQUAL 0)
|
||||
_get_gcc_features(c99 CMAKE_C99_COMPILE_FEATURES)
|
||||
endif()
|
||||
if (_result EQUAL 0)
|
||||
_get_gcc_features(c11 CMAKE_C11_COMPILE_FEATURES)
|
||||
endif()
|
||||
else()
|
||||
set(_result 0)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
Reference in New Issue
Block a user