diff options
author | Stephen Kelly <steveire@gmail.com> | 2013-11-04 00:15:43 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2014-05-14 22:15:18 (GMT) |
commit | e0890d03a48d12904ffe24aa94fb2847d8d5f4e7 (patch) | |
tree | 820631dcc5cd8c95111dbfa7d33e1a59d554f8a4 /Modules/WriteCompilerDetectionHeader.cmake | |
parent | 775458dede98d28fe81ac878541a6ead735443fc (diff) | |
download | CMake-e0890d03a48d12904ffe24aa94fb2847d8d5f4e7.zip CMake-e0890d03a48d12904ffe24aa94fb2847d8d5f4e7.tar.gz CMake-e0890d03a48d12904ffe24aa94fb2847d8d5f4e7.tar.bz2 |
Features: Extend concept to C language.
Add properties and variables corresponding to CXX equivalents.
Add features for c_function_prototypes (C90), c_restrict (C99),
c_variadic_macros (C99) and c_static_assert (C11). This feature
set can be extended later.
Add a <PREFIX>_RESTRICT symbol define to WriteCompilerDetectionHeader
to conditionally represent the c_restrict feature.
Diffstat (limited to 'Modules/WriteCompilerDetectionHeader.cmake')
-rw-r--r-- | Modules/WriteCompilerDetectionHeader.cmake | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake index fd236c1..d3c2037 100644 --- a/Modules/WriteCompilerDetectionHeader.cmake +++ b/Modules/WriteCompilerDetectionHeader.cmake @@ -43,7 +43,8 @@ # Possible compiler identifiers are documented with the # :variable:`CMAKE_<LANG>_COMPILER_ID` variable. # Available features in this version of CMake are listed in the -# :prop_gbl:`CMAKE_CXX_KNOWN_FEATURES` global property. +# :prop_gbl:`CMAKE_C_KNOWN_FEATURES` and +# :prop_gbl:`CMAKE_CXX_KNOWN_FEATURES` global properties. # # Feature Test Macros # =================== @@ -102,6 +103,7 @@ # ========================== =================================== ================= # Feature Define Symbol # ========================== =================================== ================= +# ``c_restrict`` ``<PREFIX>_RESTRICT`` ``restrict`` # ``cxx_constexpr`` ``<PREFIX>_CONSTEXPR`` ``constexpr`` # ``cxx_deleted_functions`` ``<PREFIX>_DELETED_FUNCTION`` ``= delete`` # ``cxx_extern_templates`` ``<PREFIX>_EXTERN_TEMPLATE`` ``extern`` @@ -221,6 +223,9 @@ function(write_compiler_detection_header if (feature MATCHES "^cxx_") list(APPEND _langs CXX) list(APPEND CXX_features ${feature}) + elseif (feature MATCHES "^c_") + list(APPEND _langs C) + list(APPEND C_features ${feature}) else() message(FATAL_ERROR "Unsupported feature ${feature}.") endif() @@ -239,6 +244,8 @@ function(write_compiler_detection_header if(_lang STREQUAL CXX) set(file_content "${file_content}\n#ifdef __cplusplus\n") + else() + set(file_content "${file_content}\n#ifndef __cplusplus\n") endif() compiler_id_detection(ID_CONTENT ${_lang} PREFIX ${prefix_arg}_ @@ -279,6 +286,16 @@ function(write_compiler_detection_header string(TOUPPER ${feature} feature_upper) set(feature_PP "COMPILER_${feature_upper}") set(def_name ${prefix_arg}_${feature_PP}) + if (feature STREQUAL c_restrict) + set(def_value "${prefix_arg}_RESTRICT") + set(file_content "${file_content} +# if ${def_name} +# define ${def_value} restrict +# else +# define ${def_value} +# endif +\n") + endif() if (feature STREQUAL cxx_constexpr) set(def_value "${prefix_arg}_DECL_${feature_upper}") set(file_content "${file_content} @@ -382,9 +399,8 @@ function(write_compiler_detection_header \n") endif() endforeach() - if(_lang STREQUAL CXX) - set(file_content "${file_content}#endif\n") - endif() + + set(file_content "${file_content}#endif\n") endforeach() |