CMP0180.rst 1.7 KB

123456789101112131415161718192021222324252627282930313233343536
  1. CMP0180
  2. -------
  3. .. versionadded:: 3.31
  4. :command:`project` always sets ``<PROJECT-NAME>_*`` as normal variables.
  5. In CMake 3.29 and below, the :command:`project` command set
  6. :variable:`<PROJECT-NAME>_SOURCE_DIR`, :variable:`<PROJECT-NAME>_BINARY_DIR`,
  7. and :variable:`<PROJECT-NAME>_IS_TOP_LEVEL` as cache entries, but not as
  8. normal variables. CMake 3.30 started setting them as normal variables,
  9. but only if they are already set as normal variables. This was needed to
  10. preserve support for some :module:`FetchContent` use cases under policy
  11. :policy:`CMP0169`'s NEW behavior, while also preserving behavior of nested
  12. directories that call :command:`project` with the same project name.
  13. See release notes for 3.30.3, 3.30.4, and 3.30.5 for details.
  14. CMake 3.31 and later prefer to always set ``<PROJECT-NAME>_SOURCE_DIR``,
  15. ``<PROJECT-NAME>_BINARY_DIR``, and ``<PROJECT-NAME>_IS_TOP_LEVEL``, as both
  16. cache entries and normal variables, regardless of what cache or normal
  17. variables already exist. This policy provides compatibility for projects
  18. that have not been updated to expect this behavior.
  19. The ``OLD`` behavior for this policy will only set normal variables for
  20. ``<PROJECT-NAME>_SOURCE_DIR``, ``<PROJECT-NAME>_BINARY_DIR``, and
  21. ``<PROJECT-NAME>_IS_TOP_LEVEL`` if there is already a normal variable by that
  22. name when :command:`project` is called.
  23. The ``NEW`` behavior for this policy will always set normal variables for
  24. ``<PROJECT-NAME>_SOURCE_DIR``, ``<PROJECT-NAME>_BINARY_DIR``, and
  25. ``<PROJECT-NAME>_IS_TOP_LEVEL`` when :command:`project` is called.
  26. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.31
  27. .. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn
  28. .. include:: include/STANDARD_ADVICE.rst
  29. .. include:: include/DEPRECATED.rst