1unset
2-----
3
4Unset a variable, cache variable, or environment variable.
5
6Unset Normal Variable or Cache Entry
7^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8
9.. code-block:: cmake
10
11  unset(<variable> [CACHE | PARENT_SCOPE])
12
13Removes a normal variable from the current scope, causing it
14to become undefined.  If ``CACHE`` is present, then a cache variable
15is removed instead of a normal variable.  Note that when evaluating
16:ref:`Variable References` of the form ``${VAR}``, CMake first searches
17for a normal variable with that name.  If no such normal variable exists,
18CMake will then search for a cache entry with that name.  Because of this
19unsetting a normal variable can expose a cache variable that was previously
20hidden.  To force a variable reference of the form ``${VAR}`` to return an
21empty string, use ``set(<variable> "")``, which clears the normal variable
22but leaves it defined.
23
24If ``PARENT_SCOPE`` is present then the variable is removed from the scope
25above the current scope.  See the same option in the :command:`set` command
26for further details.
27
28Unset Environment Variable
29^^^^^^^^^^^^^^^^^^^^^^^^^^
30
31.. code-block:: cmake
32
33  unset(ENV{<variable>})
34
35Removes ``<variable>`` from the currently available
36:manual:`Environment Variables <cmake-env-variables(7)>`.
37Subsequent calls of ``$ENV{<variable>}`` will return the empty string.
38
39This command affects only the current CMake process, not the process
40from which CMake was called, nor the system environment at large,
41nor the environment of subsequent build or test processes.
42