CMP0168.rst 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. CMP0168
  2. -------
  3. .. versionadded:: 3.30
  4. The :module:`FetchContent` module implements steps directly instead of through
  5. a sub-build.
  6. CMake 3.29 and below implement FetchContent as a separate sub-build.
  7. This required configuring that separate project and using a build tool.
  8. This approach can be very slow with some generators and operating systems.
  9. CMake 3.30 and above prefer to implement the download, update, and patch
  10. steps directly as part of the main project.
  11. The ``NEW`` behavior has the following characteristics:
  12. * No sub-build is used. All operations are implemented directly from the
  13. main project's CMake configure step. When running in CMake script mode,
  14. no build tool needs to be available.
  15. * Generator expressions and GNU Make variables of the form ``$(SOMEVAR)`` are
  16. not supported. They should not be used in any argument to
  17. :command:`FetchContent_Declare` or :command:`FetchContent_Populate`.
  18. * All ``LOG_...`` and ``USES_TERMINAL_...`` options, the ``QUIET`` option, and
  19. the :variable:`FETCHCONTENT_QUIET` variable are ignored.
  20. :module:`FetchContent` output is always part of the main project's configure
  21. output. This also means it now respects the message logging level (see
  22. :variable:`CMAKE_MESSAGE_LOG_LEVEL` and
  23. :option:`--log-level <cmake --log-level>`). The default message log level
  24. should be comparable to using ``QUIET`` with the ``OLD`` policy setting,
  25. except that warnings will now be shown.
  26. * The ``PREFIX``, ``TMP_DIR``, ``STAMP_DIR``, ``LOG_DIR``, and ``DOWNLOAD_DIR``
  27. options and their associated directory properties are ignored. The
  28. :module:`FetchContent` module controls those locations internally.
  29. * :option:`cmake --fresh` will remove the stamp and script files used for
  30. tracking and populating the dependency. This will force the dependency's
  31. download, update, and patch steps to be re-executed. The directory used for
  32. downloads is not affected by :option:`cmake --fresh`, so any previously
  33. downloaded files for the ``URL`` download method can still be re-used.
  34. The ``OLD`` behavior has the following characteristics:
  35. * A sub-build is always used to implement the download, update, and patch
  36. steps. A build tool must be available, even when using
  37. :command:`FetchContent_Populate` in CMake script mode.
  38. * Generator expressions and GNU Make variables of the form ``$(SOMEVAR)`` can
  39. be used, although such use is almost always inappropriate. They are evaluated
  40. in the sub-build, so they do not see any information from the main build.
  41. * All logging, terminal control, and directory options related to the download,
  42. update, or patch steps are supported.
  43. * If the ``QUIET`` option is used, or the :variable:`FETCHCONTENT_QUIET`
  44. variable is set to true, warnings will not be shown in the output.
  45. * :option:`cmake --fresh` has no effect on the dependency's stamp or script
  46. files. Previously executed steps will only re-run if details about the
  47. dependency have changed.
  48. There's a reasonably good chance that users can set the
  49. :variable:`CMAKE_POLICY_DEFAULT_CMP0168 <CMAKE_POLICY_DEFAULT_CMP<NNNN>>`
  50. variable to ``NEW`` to globally switch to the ``NEW`` behavior while waiting
  51. for the project and its dependencies to be updated use the ``NEW`` policy
  52. setting by default. Projects don't typically make use of the features that the
  53. ``NEW`` behavior no longer supports, and even those projects that do will often
  54. still work fine when those options are ignored. Before setting this behavior
  55. globally, check whether any :command:`FetchContent_Declare` or
  56. :command:`FetchContent_Populate` calls use the ignored options in a way that
  57. would change observable behavior, other than putting temporary or
  58. internally-generated files in different locations.
  59. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.30
  60. .. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn
  61. .. include:: STANDARD_ADVICE.txt
  62. .. include:: DEPRECATED.txt