ProjectVariable

Utilities for defining and manipulating project-specific cache variables.

Defined functions:

project_variable()

Define a project variable: a project-specific cache variable with optional propagation to dependent packages via find_package().

cet_get_pv_property()

Get the value of a property-like attribute attached to a particular project variable.

cet_set_pv_property()

Set or add to a property-like attribute attached to a particular project variable.

cet_get_pv_property

Get the value of a property-like attribute attached to a particular project variable.

cet_get_pv_property([<out-var>] [PROJECT] <project-name> <var-name> PROPERTY <property>)

Options

[PROJECT] <project-name>

Find project variable <var-name> in project <project-name> (default ${CETMODULES_CURRENT_PROJECT_NAME}). If <out-var> is specified, the PROJECT keyword is optional.

PROPERTY <property>

The property-like attribute of project variable <var-name> whose value(s) should be returned in <out-var>.

Non-option arguments

[<out-var>]

The variable in which the value(s) of project variable <var-name> in project <project-name> shall be returned. If not specified, the property’s values shall be returned in a variable in caller’s scope whose name is <property>.

cet_set_pv_property

Set or append values to a property-like attribute attached to a particular project variable.

cet_set_pv_property([<project-name>] <var-name> [APPEND|APPEND_STRING] PROPERTY <property> [<value> ...])

Options

PROPERTY <property>

The property-like attribute of project variable <var-name> whose value(s) should be returned in <out-var>.

APPEND

<property> shall be treated as a list for the purposes of appending <value> ....

APPEND_STRING

<property> shall be treated as a string for the purposes of appending <value> ....

Non-option arguments

<project-name>

Find project variable <var-name> in project <project-name> (default ${CETMODULES_CURRENT_PROJECT_NAME}).

<value> ...

The item(s) to be set for or appended to <property>.

project_variable

Define a project-specific cache variable ${CETMODULES_CURRENT_PROJECT_NAME}_<var-name>, extending the functionality of set(... CACHE ...). Optionally ensure that the variable is appropriately defined for dependents via find_package().

project_variable(<var-name> [<options>] [<init-val> ...])

Options

BACKUP_DEFAULT <default-val> ...

If <init-val> evaluates to FALSE then <default-val> ... will be the initial value of the cached variable.

CONFIG

Add the defined project variable to ${CETMODULES_CURRENT_PROJECT_NAME}Config.cmake for propagation to dependent packages—in a location-independent way if appropriate to the variable’s TYPE—via find_package().

DOCSTRING <docstring>

A string describing the variable (defaults to a generic description).

MISSING_OK

A project variable whose TYPE matches ^(FILE)?PATH(_FRAGMENT)?$ but whose value does not represent a valid path in the installation area will cause an error at find_package()-time unless this option is specified.

NO_WARN_DUPLICATE

Do not warn about multiple attempts to define the same project variable in the same project.

NO_WARN_REDUNDANT

Do not warn about redundant options (e.g. if CONFIG is not specified).

OMIT_IF_EMPTY

If specified, a project variable representing a directory (i.e. whose TYPE matches ^PATH(_FRAGMENT)?$) will be omitted from ${CETMODULES_CURRENT_PROJECT_NAME}Config.cmake if it contains no entries other than . and ..

OMIT_IF_MISSING

If specified, a project variable whose TYPE matches ^(FILE)?PATH(_FRAGMENT)?$ but whose value does not represent an existing file or directory in the installation area will be omitted from ${CETMODULES_CURRENT_PROJECT_NAME}Config.cmake.

OMIT_IF_NULL

If specified, the definition of a vacuous project variable will be omitted from ${CETMODULES_CURRENT_PROJECT_NAME}Config.cmake.

PUBLIC

Project variables will generally be marked “advanced”—not visible by default in CMake configuration GUIs or to cmake -N -L in the absence of the -A option. Specifying PUBLIC will negate this.

See also

mark_as_advanced().

TYPE <type>

Define the `project-variables-types`_ type of the project variable (default PATH_FRAGMENT).

Non-option arguments

<var-name>

The name of the cached variable will be ${CETMODULES_CURRENT_PROJECT_NAME}_<var-name>

<init-val> ...

The initial value(s) of the cached variable.

Details

Order of precedence for the initial value of ${CETMODULES_CURRENT_PROJECT_NAME}_<var-name>:

  1. The value of a CMake variable ${CETMODULES_CURRENT_PROJECT_NAME}_<var-name> if it is defined in the current scope (that in which project_variable() is called) prior to the definition of the project variable.

  2. The value of a CMake variable <var-name> if it is defined in the current scope prior to the definition of the project variable.

  3. The value of a CMake or cached variable ${CETMODULES_CURRENT_PROJECT_VARIABLE_PREFIX}_<var-name>.

  4. The value of a CMake or cached variable ${CETMODULES_CURRENT_PROJECT_NAME}_<var-name>_INIT.

  5. <init-val> ....

  6. <backup-var> ... if specified and <init-val> ... evaluates to FALSE).