CMP0126.rst 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. CMP0126
  2. -------
  3. .. versionadded:: 3.21
  4. When this policy is set to ``NEW``, the :command:`set(CACHE)` command does not
  5. remove any normal variable of the same name from the current scope.
  6. The ``OLD`` behavior removes any normal variable of the same name from the
  7. current scope in the following situations:
  8. * No cache variable of that name existed previously.
  9. * A cache variable of that name existed previously, but it had no type.
  10. This can occur when the variable was set on the command line using a form
  11. like ``cmake -DMYVAR=blah`` instead of ``cmake -DMYVAR:STRING=blah``.
  12. * The ``FORCE`` or ``INTERNAL`` keywords were used when setting the cache
  13. variable.
  14. Note that the ``NEW`` behavior has an important difference to the similar
  15. ``NEW`` behavior of policy :policy:`CMP0077`. The :command:`set(CACHE)`
  16. command always sets the cache variable if it did not exist previously,
  17. regardless of the ``CMP0126`` policy setting. The :command:`option` command
  18. will *not* set the cache variable if a non-cache variable of the same name
  19. already exists and :policy:`CMP0077` is set to ``NEW``.
  20. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.21
  21. .. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn by default
  22. .. include:: STANDARD_ADVICE.txt
  23. See documentation of the
  24. :variable:`CMAKE_POLICY_WARNING_CMP0126 <CMAKE_POLICY_WARNING_CMP<NNNN>>`
  25. variable to control the warning.
  26. The :variable:`CMAKE_POLICY_DEFAULT_CMP0126 <CMAKE_POLICY_DEFAULT_CMP\<NNNN\>>`
  27. variable may be used to set the policy for a third-party project in a
  28. subdirectory without modifying it.
  29. .. include:: DEPRECATED.txt