CheckTypeSize: Modernize and clarify documentation

Spell out the list of result variables as a definition list rather
than in prose.

Fixes: #23247
This commit is contained in:
Brad King
2022-02-18 11:33:06 -05:00
parent a1cb448580
commit 65e4d29e35
+36 -29
View File
@@ -7,46 +7,53 @@ CheckTypeSize
Check sizeof a type Check sizeof a type
.. command:: CHECK_TYPE_SIZE .. command:: check_type_size
.. code-block:: cmake .. code-block:: cmake
CHECK_TYPE_SIZE(TYPE VARIABLE [BUILTIN_TYPES_ONLY] check_type_size(<type> <variable> [BUILTIN_TYPES_ONLY]
[LANGUAGE <language>]) [LANGUAGE <language>])
Check if the type exists and determine its size. On return, Check if the type exists and determine its size. Results are reported
``HAVE_${VARIABLE}`` holds the existence of the type, and ``${VARIABLE}`` in the following variables:
holds one of the following:
:: ``HAVE_<variable>``
Holds a true or false value indicating whether the type exists.
<size> = type has non-zero size <size> ``<variable>``
"0" = type has arch-dependent size (see below) Holds one of the following values:
"" = type does not exist
Both ``HAVE_${VARIABLE}`` and ``${VARIABLE}`` will be created as internal ``<size>``
cache variables. Type has non-zero size ``<size>``.
Furthermore, the variable ``${VARIABLE}_CODE`` holds C preprocessor code ``0``
to define the macro ``${VARIABLE}`` to the size of the type, or leave Type has architecture-dependent size. This may occur when
the macro undefined if the type does not exist. :variable:`CMAKE_OSX_ARCHITECTURES` has multiple architectures.
In this case ``<variable>_CODE`` contains C preprocessor tests
mapping from each architecture macro to the corresponding type size.
The list of architecture macros is stored in ``<variable>_KEYS``,
and the value for each key is stored in ``<variable>-<key>``.
The variable ``${VARIABLE}`` may be ``0`` when "" (empty string)
:variable:`CMAKE_OSX_ARCHITECTURES` has multiple architectures for building Type does not exist.
OS X universal binaries. This indicates that the type size varies across
architectures. In this case ``${VARIABLE}_CODE`` contains C preprocessor
tests mapping from each architecture macro to the corresponding type size.
The list of architecture macros is stored in ``${VARIABLE}_KEYS``, and the
value for each key is stored in ``${VARIABLE}-${KEY}``.
If the ``BUILTIN_TYPES_ONLY`` option is not given, the macro checks for ``<variable>_CODE``
headers ``<sys/types.h>``, ``<stdint.h>``, and ``<stddef.h>``, and saves Holds C preprocessor code to define the macro ``<variable>`` to the size
results in ``HAVE_SYS_TYPES_H``, ``HAVE_STDINT_H``, and ``HAVE_STDDEF_H``. of the type, or to leave the macro undefined if the type does not exist.
The type size check automatically includes the available headers, thus
supporting checks of types defined in the headers.
If ``LANGUAGE`` is set, the specified compiler will be used to perform the The options are:
check. Acceptable values are ``C`` and ``CXX``.
``BUILTIN_TYPES_ONLY``
Support only compiler-builtin types. If *not* given, the macro checks
for headers ``<sys/types.h>``, ``<stdint.h>``, and ``<stddef.h>``, and
saves results in ``HAVE_SYS_TYPES_H``, ``HAVE_STDINT_H``, and
``HAVE_STDDEF_H``. The type size check automatically includes the
available headers, thus supporting checks of types defined in the headers.
``LANGUAGE <language>``
Use the ``<language>`` compiler to perform the check.
Acceptable values are ``C`` and ``CXX``.
Despite the name of the macro you may use it to check the size of more Despite the name of the macro you may use it to check the size of more
complex expressions, too. To check e.g. for the size of a struct complex expressions, too. To check e.g. for the size of a struct