unset.rst 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. unset
  2. -----
  3. Unset a variable, cache variable, or environment variable.
  4. .. code-block:: cmake
  5. unset(<variable> [CACHE | PARENT_SCOPE])
  6. Removes a normal variable from the current scope, causing it
  7. to become undefined. If ``CACHE`` is present, then a cache variable
  8. is removed instead of a normal variable. Note that when evaluating
  9. :ref:`Variable References` of the form ``${VAR}``, CMake first searches
  10. for a normal variable with that name. If no such normal variable exists,
  11. CMake will then search for a cache entry with that name. Because of this
  12. unsetting a normal variable can expose a cache variable that was previously
  13. hidden. To force a variable reference of the form ``${VAR}`` to return an
  14. empty string, use ``set(<variable> "")``, which clears the normal variable
  15. but leaves it defined.
  16. If ``PARENT_SCOPE`` is present then the variable is removed from the scope
  17. above the current scope. See the same option in the :command:`set` command
  18. for further details.
  19. ``<variable>`` can be an environment variable such as:
  20. .. code-block:: cmake
  21. unset(ENV{LD_LIBRARY_PATH})
  22. in which case the variable will be removed from the current
  23. environment.