get_option()

Obtains the value of the project build option specified in the positional argument.

Note that the value returned for built-in options that end in dir such as bindir and libdir is usually a path relative to (and inside) the prefix but you should not rely on that, as it can also be an absolute path in some cases. install_dir arguments handle that as expected but if you need an absolute path, e.g. to use in a define etc., you should use the path concatenation operator like this: get_option('prefix') / get_option('localstatedir'). Never manually join paths as if they were strings.

For options of type feature a feature option object is returned instead of a string. See feature options documentation for more details.

For options that are specified per-machine get_option() retrieves the value of the option for the build machine if the argument starts with build..

Signature

# Obtains the value of the [project build option](Build-options
str | int | bool | feature | array[str | int | bool] get_option(
  str option_name,     # Name of the option to query
)

Arguments

The function get_option() accepts the following positional arguments:

Name Type Description Tags
option_name str

Name of the option to query

The results of the search are