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 /Help | |
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 'Help')
-rw-r--r-- | Help/command/target_compile_features.rst | 3 | ||||
-rw-r--r-- | Help/manual/cmake-properties.7.rst | 4 | ||||
-rw-r--r-- | Help/manual/cmake-variables.7.rst | 4 | ||||
-rw-r--r-- | Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst | 25 | ||||
-rw-r--r-- | Help/prop_tgt/C_EXTENSIONS.rst | 8 | ||||
-rw-r--r-- | Help/prop_tgt/C_STANDARD.rst | 27 | ||||
-rw-r--r-- | Help/prop_tgt/C_STANDARD_REQUIRED.rst | 14 | ||||
-rw-r--r-- | Help/release/dev/compile-language-features.rst | 6 | ||||
-rw-r--r-- | Help/variable/CMAKE_C_COMPILE_FEATURES.rst | 8 | ||||
-rw-r--r-- | Help/variable/CMAKE_C_EXTENSIONS.rst | 8 | ||||
-rw-r--r-- | Help/variable/CMAKE_C_STANDARD.rst | 8 | ||||
-rw-r--r-- | Help/variable/CMAKE_C_STANDARD_REQUIRED.rst | 8 |
12 files changed, 122 insertions, 1 deletions
diff --git a/Help/command/target_compile_features.rst b/Help/command/target_compile_features.rst index f8e5c54..9559600 100644 --- a/Help/command/target_compile_features.rst +++ b/Help/command/target_compile_features.rst @@ -8,7 +8,8 @@ Add expected compiler features to a target. target_compile_features(<target> <PRIVATE|PUBLIC|INTERFACE> <feature> [...]) Specify compiler features required when compiling a given target. If the -feature is not listed in the :variable:`CMAKE_CXX_COMPILE_FEATURES` variable, +feature is not listed in the :variable:`CMAKE_C_COMPILE_FEATURES` variable +or :variable:`CMAKE_CXX_COMPILE_FEATURES` variable, then an error will be reported by CMake. If the use of the feature requires an additional compiler flag, such as ``-std=c++11``, the flag will be added automatically. diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 14d2e7f..a204a9c 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -16,6 +16,7 @@ Properties of Global Scope /prop_gbl/ALLOW_DUPLICATE_CUSTOM_TARGETS /prop_gbl/AUTOGEN_TARGETS_FOLDER /prop_gbl/AUTOMOC_TARGETS_FOLDER + /prop_gbl/CMAKE_C_KNOWN_FEATURES /prop_gbl/CMAKE_CXX_KNOWN_FEATURES /prop_gbl/DEBUG_CONFIGURATIONS /prop_gbl/DISABLED_FEATURES @@ -93,6 +94,9 @@ Properties on Targets /prop_tgt/BUILD_WITH_INSTALL_RPATH /prop_tgt/BUNDLE_EXTENSION /prop_tgt/BUNDLE + /prop_tgt/C_EXTENSIONS + /prop_tgt/C_STANDARD + /prop_tgt/C_STANDARD_REQUIRED /prop_tgt/COMPATIBLE_INTERFACE_BOOL /prop_tgt/COMPATIBLE_INTERFACE_NUMBER_MAX /prop_tgt/COMPATIBLE_INTERFACE_NUMBER_MIN diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index a7d4af6..b2dc88f 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -260,6 +260,10 @@ Variables for Languages :maxdepth: 1 /variable/CMAKE_COMPILER_IS_GNULANG + /variable/CMAKE_C_COMPILE_FEATURES + /variable/CMAKE_C_EXTENSIONS + /variable/CMAKE_C_STANDARD + /variable/CMAKE_C_STANDARD_REQUIRED /variable/CMAKE_CXX_COMPILE_FEATURES /variable/CMAKE_CXX_EXTENSIONS /variable/CMAKE_CXX_STANDARD diff --git a/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst new file mode 100644 index 0000000..c57bc73 --- /dev/null +++ b/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst @@ -0,0 +1,25 @@ +CMAKE_C_KNOWN_FEATURES +---------------------- + +List of C features known to this version of CMake. + +The features listed in this global property may be known to be available to the +C compiler. If the feature is available with the C compiler, it will +be listed in the :variable:`CMAKE_C_COMPILE_FEATURES` variable. + +The features listed here may be used with the :command:`target_compile_features` +command. + +The features known to this version of CMake are: + +``c_function_prototypes`` + Function prototypes, as defined in ``ISO/IEC 9899:1990``. + +``c_restrict`` + ``restrict`` keyword, as defined in ``ISO/IEC 9899:1999``. + +``c_static_assert`` + Static assert, as defined in ``ISO/IEC 9899:2011``. + +``c_variadic_macros`` + Variadic macros, as defined in ``ISO/IEC 9899:1999``. diff --git a/Help/prop_tgt/C_EXTENSIONS.rst b/Help/prop_tgt/C_EXTENSIONS.rst new file mode 100644 index 0000000..246e93d --- /dev/null +++ b/Help/prop_tgt/C_EXTENSIONS.rst @@ -0,0 +1,8 @@ +C_EXTENSIONS +------------ + +Boolean specifying whether compiler specific extensions are requested. + +This property specifies whether compiler specific extensions should be +used. For some compilers, this results in adding a flag such +as ``-std=gnu11`` instead of ``-std=c11`` to the compile line. diff --git a/Help/prop_tgt/C_STANDARD.rst b/Help/prop_tgt/C_STANDARD.rst new file mode 100644 index 0000000..9fdc0bb --- /dev/null +++ b/Help/prop_tgt/C_STANDARD.rst @@ -0,0 +1,27 @@ +C_STANDARD +---------- + +The C standard whose features are requested to build this target. + +This property specifies the C standard whose features are requested +to build this target. For some compilers, this results in adding a +flag such as ``-std=c11`` to the compile line. + +Supported values are ``90``, ``99`` and ``11``. + +If the value requested does not result in a compile flag being added for +the compiler in use, a previous standard flag will be added instead. This +means that using: + +.. code-block:: cmake + + set_property(TARGET tgt PROPERTY C_STANDARD 11) + +with a compiler which does not support ``-std=c11`` or an equivalent +flag will not result in an error or warning, but will instead add the +``-std=c99`` or ``-std=c90`` flag if supported. This "decay" behavior may +be controlled with the :prop_tgt:`C_STANDARD_REQUIRED` target property. + +This property is initialized by the value of +the :variable:`CMAKE_C_STANDARD` variable if it is set when a target +is created. diff --git a/Help/prop_tgt/C_STANDARD_REQUIRED.rst b/Help/prop_tgt/C_STANDARD_REQUIRED.rst new file mode 100644 index 0000000..6c39e96 --- /dev/null +++ b/Help/prop_tgt/C_STANDARD_REQUIRED.rst @@ -0,0 +1,14 @@ +C_STANDARD_REQUIRED +------------------- + +Boolean describing whether the value of :prop_tgt:`C_STANDARD` is a requirement. + +If this property is set to ``ON``, then the value of the +:prop_tgt:`C_STANDARD` target property is treated as a requirement. If this +property is ``OFF`` or unset, the :prop_tgt:`C_STANDARD` target property is +treated as optional and may "decay" to a previous standard if the requested is +not available. + +This property is initialized by the value of +the :variable:`CMAKE_C_STANDARD_REQUIRED` variable if it is set when a +target is created. diff --git a/Help/release/dev/compile-language-features.rst b/Help/release/dev/compile-language-features.rst index 3c5d7ca..fe72e39 100644 --- a/Help/release/dev/compile-language-features.rst +++ b/Help/release/dev/compile-language-features.rst @@ -7,6 +7,12 @@ target-language-features :variable:`CMAKE_CXX_STANDARD` and :variable:`CMAKE_CXX_EXTENSIONS` variables may be set to initialize the target properties. +* New :prop_tgt:`C_STANDARD` and :prop_tgt:`C_EXTENSIONS` target + properties may specify values which CMake uses to compute required + compile options such as ``-std=c11`` or ``-std=gnu11``. The + :variable:`CMAKE_C_STANDARD` and :variable:`CMAKE_C_EXTENSIONS` + variables may be set to initialize the target properties. + * New :prop_tgt:`COMPILE_FEATURES` target property may contain a list of features required to compile a target. CMake uses this information to ensure that the compiler in use is capable of building diff --git a/Help/variable/CMAKE_C_COMPILE_FEATURES.rst b/Help/variable/CMAKE_C_COMPILE_FEATURES.rst new file mode 100644 index 0000000..7d1c8b1 --- /dev/null +++ b/Help/variable/CMAKE_C_COMPILE_FEATURES.rst @@ -0,0 +1,8 @@ +CMAKE_C_COMPILE_FEATURES +------------------------ + +List of features known to the C compiler + +These features are known to be available for use with the C compiler. This +list is a subset of the features listed in the :prop_gbl:`CMAKE_C_KNOWN_FEATURES` +global property. diff --git a/Help/variable/CMAKE_C_EXTENSIONS.rst b/Help/variable/CMAKE_C_EXTENSIONS.rst new file mode 100644 index 0000000..ff2569b --- /dev/null +++ b/Help/variable/CMAKE_C_EXTENSIONS.rst @@ -0,0 +1,8 @@ +CMAKE_C_EXTENSIONS +------------------ + +Default value for ``C_EXTENSIONS`` property of targets. + +This variable is used to initialize the :prop_tgt:`C_EXTENSIONS` +property on all targets. See that target property for additional +information. diff --git a/Help/variable/CMAKE_C_STANDARD.rst b/Help/variable/CMAKE_C_STANDARD.rst new file mode 100644 index 0000000..c1f8c29 --- /dev/null +++ b/Help/variable/CMAKE_C_STANDARD.rst @@ -0,0 +1,8 @@ +CMAKE_C_STANDARD +---------------- + +Default value for ``C_STANDARD`` property of targets. + +This variable is used to initialize the :prop_tgt:`C_STANDARD` +property on all targets. See that target property for additional +information. diff --git a/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst b/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst new file mode 100644 index 0000000..13ea49f --- /dev/null +++ b/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst @@ -0,0 +1,8 @@ +CMAKE_C_STANDARD_REQUIRED +------------------------- + +Default value for ``C_STANDARD_REQUIRED`` property of targets. + +This variable is used to initialize the :prop_tgt:`C_STANDARD_REQUIRED` +property on all targets. See that target property for additional +information. |