Utilities#

The utilities module contains miscellaneous commands such as defining enums or required arguments.

toolbelt_enum#

A macro which checks whether only one out of a set of variables is truthy and returns an error if not. This is useful to define enum options which can be one out of a set of defined values.

toolbelt_enum(
    <variables...>
)

This macro returns an error in the scope of the calling code, if more than one variable in variables evaluates to true.

Note

This function assumes that variables prefixed with _ should be used without this prefix. This is used to format arguments parsed by cmake_parse_arguments.

Examples#

Check if an enum is set#

This checks if only one out of A, B, and C is truthy and returns early if not.

toolbelt_enum(
    A
    B
    C
)

toolbelt_required#

A macro which checks whether an argument is truthy and returns an error if not. This can be used to confirm the presence of arguments parsed by cmake_parse_arguments.

toolbelt_required(
    <arg>
)

This macro returns an error in the scope of the calling code if arg is not truthy.

Examples#

Check if an argument is set#

This checks if arg is defined and evaluates to true:

toolbelt_required(
    arg
)