cmaize.user_api/cmaize_option
- cmaize.user_api/cmaize_option.cmaize_option(_co_name _co_default_value _co_docstring)
Registers a configuration option with the current project.
Note
Unlike CMake’s
option
command values are not restricted to booleans.Build system mainainers can declare configuration options for their build system via the
cmaize_option
function. Consistent with usual build sytem behavior, users can override the default value. Assuming a call tocmaize_option
likecmaize_option(option_name option_value option_description)
, users of the build system can set the value of theoption_name
option by:setting a
option_name
variable before callingcmaize_option
,setting a
option_name
cache variable before callingcmaize_option
, or bysetting the configuration option
option_name
on the project’s CMaizeProject object directly (not recommended for end users).
If the user has not set the value via any of the above mechanisms
cmaize_option
will set the value ofoption_name
tooption_value
.After calling this function the CMake variable
option_name
is guaranteed to be set. Similar to CMake’soption
command, the CMake cache variableoption_name
will be set if a normal (or cache) CMake variableoption_name
was not already set.- Parameters:
name (desc) – The name of the configuration option being set.
default_value (str) – The value to set
name
to if the user does not provide a value.docstring (str) – A brief description of what the option does. This parameter’s value is used primarily as metadata.
- cmaize.user_api/cmaize_option.cmaize_option_list()
Convenience function for registering a number of options with CMaize.
Many projects have multiple configuration options. Rather than having to call
cmaize_option
for each option,cmaize_option_list
allows you to provide a list of key/value pairs. Under the hood this function simply loops over the key/value pairs and forwards them tocmaize_option
, thus all documentation relating tocmaize_option
applies here as well.- Parameters:
*args –
A variadiac list of key/value pairs. The
2i
-th argument will be interpretted as the key for thei
-th pair and the2i + 1
-th argument will be interpretted as the value for thei
-th pair.- Raises:
input_error – If the number of arguments is not divisible by 2.