cmake/Help/command/math.rst

31 lines
940 B
ReStructuredText
Raw Normal View History

2014-08-03 19:52:23 +02:00
math
----
Mathematical expressions.
::
2018-10-28 12:09:07 +01:00
math(EXPR <output-variable> <math-expression> [OUTPUT_FORMAT <format>])
2014-08-03 19:52:23 +02:00
2015-11-17 17:22:37 +01:00
``EXPR`` evaluates mathematical expression and returns result in the
2016-10-30 18:24:19 +01:00
output variable. Example mathematical expression is ``5 * (10 + 13)``.
Supported operators are ``+``, ``-``, ``*``, ``/``, ``%``, ``|``, ``&``,
``^``, ``~``, ``<<``, ``>>``, and ``(...)``. They have the same meaning
as they do in C code.
2018-10-28 12:09:07 +01:00
Numeric constants are evaluated in decimal or hexadecimal representation.
The result is formatted according to the option "OUTPUT_FORMAT" ,
where ``<format>`` is one of:
::
HEXADECIMAL = Result in output variable will be formatted in C code
Hexadecimal notation.
DECIMAL = Result in output variable will be formatted in decimal notation.
For example::
math(EXPR value "100 * 0xA" DECIMAL) results in value is set to "1000"
math(EXPR value "100 * 0xA" HEXADECIMAL) results in value is set to "0x3e8"