unset.rst 1.5 KB

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