3.21.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. CMake 3.21 Release Notes
  2. ************************
  3. .. only:: html
  4. .. contents::
  5. Changes made since CMake 3.20 include the following.
  6. New Features
  7. ============
  8. Presets
  9. -------
  10. * :manual:`cmake-presets(7)` gained support for specifying the install prefix
  11. in a configure preset.
  12. * :manual:`cmake-presets(7)` gained support for conditional enabling of presets.
  13. * :manual:`cmake-presets(7)` gained support for a ``${hostSystemName}`` macro.
  14. * :manual:`cmake-presets(7)` gained support for omitting the ``generator`` and
  15. ``binaryDir`` fields.
  16. Generators
  17. ----------
  18. * The :generator:`Visual Studio 17 2022` generator was added. This is
  19. experimental and based on "Visual Studio 2022 Preview 2" because this
  20. version of VS has not been released.
  21. * The :ref:`Makefile Generators` and the :generator:`Ninja` generator
  22. learned to add linker launcher tools along with the linker for ``C``,
  23. ``CXX``, ``OBJC``, and ``OBJCXX`` languages.
  24. See the :variable:`CMAKE_<LANG>_LINKER_LAUNCHER` variable
  25. and :prop_tgt:`<LANG>_LINKER_LAUNCHER` target property for details.
  26. Languages
  27. ---------
  28. * CMake learned to support ``HIP`` as a first-class language that can be
  29. enabled via the :command:`project` and :command:`enable_language` commands.
  30. * :prop_tgt:`C_STANDARD`, :prop_tgt:`OBJC_STANDARD`, and the
  31. :manual:`Compile Features <cmake-compile-features(7)>` functionality gained
  32. support for C17 and C23.
  33. * Source file extensions ``.ixx`` and ``.cppm`` are now treated as C++.
  34. Command-Line
  35. ------------
  36. * :manual:`cmake(1)` gained the ``--install-prefix <dir>``
  37. command-line option to specify the location of the install prefix.
  38. * :manual:`cmake(1)` gained the ``--toolchain <path/to/file>``
  39. command-line option to specify a toolchain file.
  40. * :manual:`cmake(1)` ``-E capabilities`` output, for some generators,
  41. may now contain a ``supportedPlatforms`` field listing platforms
  42. known to be supported in :variable:`CMAKE_GENERATOR_PLATFORM`.
  43. * Messages printed to a terminal now may be colored by message type.
  44. Compilers
  45. ---------
  46. * The Fujitsu compiler is now supported using compiler id ``Fujitsu``
  47. in traditional (``Trad``) mode, and compiler id ``FujitsuClang``
  48. in ``Clang`` mode.
  49. Platforms
  50. ---------
  51. * CMake now supports the MSYS runtime environment, much like CYGWIN.
  52. File-Based API
  53. --------------
  54. * The :manual:`cmake-file-api(7)` "codemodel" version 2 ``version`` field
  55. has been updated to 2.3.
  56. * The :manual:`cmake-file-api(7)` "codemodel" version 2 gained a
  57. new "directory" object containing directory-level information.
  58. This includes a list of installers generated by the :command:`install`
  59. command.
  60. Commands
  61. --------
  62. * The :command:`add_custom_command` command ``DEPFILE`` option:
  63. * may now use
  64. :manual:`generator expressions <cmake-generator-expressions(7)>`,
  65. * is now supported by :ref:`Visual Studio Generators` for VS 2012
  66. and above, and
  67. * is now supported by the :generator:`Xcode` generator.
  68. * The :command:`add_custom_command(TARGET)` command
  69. (for :ref:`Build Events <add_custom_command(TARGET)>`)
  70. gained support for resolving target-dependent generator expressions.
  71. * The :command:`build_command` command gained a ``PARALLEL_LEVEL`` option.
  72. * The :command:`file(COPY_FILE)` command was added to copy a single file.
  73. * The :command:`file(GET_RUNTIME_DEPENDENCIES)` command gained new
  74. ``POST_INCLUDE_FILES`` and ``POST_EXCLUDE_FILES`` arguments.
  75. * The :command:`file(REAL_PATH)` command gained the option ``EXPAND_TILDE`` to
  76. replace any leading tilde with the path to the user's home directory.
  77. * The :command:`file(RENAME)` command learned to optionally capture
  78. failure in a result variable. It also gained a ``NO_REPLACE``
  79. option to fail if the destination exists.
  80. * The :command:`install` command gained a new ``IMPORTED_RUNTIME_ARTIFACTS``
  81. mode, which can be used to install the runtime artifacts of imported targets.
  82. * The :command:`install` command gained a new ``RUNTIME_DEPENDENCY_SET`` mode,
  83. which can be used to install runtime dependencies using
  84. :command:`file(GET_RUNTIME_DEPENDENCIES)`.
  85. * The :command:`install(TARGETS)` command gained new ``RUNTIME_DEPENDENCIES``
  86. and ``RUNTIME_DEPENDENCY_SET`` arguments, which can be used to install
  87. runtime dependencies using :command:`file(GET_RUNTIME_DEPENDENCIES)`.
  88. * The :command:`install(SCRIPT|CODE)` command
  89. supports a new option ``ALL_COMPONENTS`` which allows
  90. the corresponding code to run for every component of
  91. a per component installation.
  92. * The :command:`project` command now sets variables
  93. :variable:`PROJECT_IS_TOP_LEVEL` and :variable:`<PROJECT-NAME>_IS_TOP_LEVEL`
  94. to indicate whether it was called in a top-level ``CMakeLists.txt`` file.
  95. Variables
  96. ---------
  97. * The :envvar:`CMAKE_TOOLCHAIN_FILE` environment variable was added to
  98. provide a default value for the :variable:`CMAKE_TOOLCHAIN_FILE` variable.
  99. Properties
  100. ----------
  101. * The :prop_dir:`IMPORTED_TARGETS` directory property was added to
  102. get a list of :ref:`Imported Targets` created in the current
  103. directory.
  104. * The :prop_tgt:`XCODE_EMBED_APP_EXTENSIONS <XCODE_EMBED_<type>>` target property
  105. was added to tell the :generator:`Xcode` generator to embed app extensions
  106. such as iMessage sticker packs.
  107. Aspects of the embedding can be customized with the
  108. :prop_tgt:`XCODE_EMBED_APP_EXTENSIONS_PATH <XCODE_EMBED_<type>>`,
  109. :prop_tgt:`XCODE_EMBED_APP_EXTENSIONS_CODE_SIGN_ON_COPY <XCODE_EMBED_<type>_CODE_SIGN_ON_COPY>` and
  110. :prop_tgt:`XCODE_EMBED_APP_EXTENSIONS_REMOVE_HEADERS_ON_COPY <XCODE_EMBED_<type>_REMOVE_HEADERS_ON_COPY>`
  111. properties.
  112. Modules
  113. -------
  114. * The :module:`FindBLAS` and :module:`FindLAPACK` modules learned to support
  115. the serial ``Fujitsu_SSL2`` and parallel ``Fujitsu_SSL2BLAMP`` libraries.
  116. * The :module:`FindDevIL` module now provides imported targets.
  117. * The :module:`FindIconv` module now has version support.
  118. * The :module:`FindIntl` module now has version support.
  119. * The :module:`FindMPI` module learned to support ``Fujitsu`` and
  120. ``FujitsuClang`` in both host and cross compiling modes.
  121. * The :module:`FindMsys` module was added to find MSYS installations.
  122. Like :module:`FindCygwin`, it is used automatically by some other
  123. find modules to locate UNIX-style tools on Windows.
  124. * The :module:`FindOpenMP` module learned to support ``Fujitsu`` and
  125. ``FujitsuClang``.
  126. * The :module:`FindVulkan` module gained imported targets
  127. ``Vulkan::Headers`` and ``Vulkan::glslangValidator``.
  128. * The :module:`UseJava` module command ``add_jar`` gained a ``RESOURCES``
  129. option to allow explicit naming of resources with non-optional namespace.
  130. * The :module:`UseSWIG` module use now standard library naming conventions
  131. for the ``CSharp`` language. See policy :policy:`CMP0122`.
  132. * The :module:`UseSWIG` module now supports using the ``swig`` tool to
  133. generate implicit dependencies with the :generator:`Xcode` generator.
  134. Generator Expressions
  135. ---------------------
  136. * A new :genex:`TARGET_RUNTIME_DLLS` generator expression was added.
  137. CTest
  138. -----
  139. * :manual:`ctest(1)` gained documentation for its ability to capture
  140. :ref:`Additional Test Measurements`.
  141. * :manual:`ctest(1)` learned to recognize files attached to a test at run time.
  142. Previously it was only possible to attach files to tests at configure time
  143. by using the :prop_test:`ATTACHED_FILES` or
  144. :prop_test:`ATTACHED_FILES_ON_FAIL` test properties.
  145. See :ref:`Additional Test Measurements` for more information.
  146. * :manual:`ctest(1)` gained a ``--output-junit`` option to write test results
  147. to a JUnit XML file.
  148. * The :command:`ctest_build` command gained a ``PARALLEL_LEVEL`` option.
  149. CPack
  150. -----
  151. * The :cpack_gen:`CPack DragNDrop Generator` gained option
  152. :variable:`CPACK_DMG_FILESYSTEM` to control the ``.dmg`` filesystem.
  153. * The :cpack_gen:`CPack IFW Generator` now supports hyphens in names
  154. given to :command:`cpack_ifw_configure_component` or
  155. :command:`cpack_ifw_configure_component_group` as ``DEPENDS`` or
  156. ``DEPENDENCIES`` arguments. This requires QtIFW 3.1 or later.
  157. * The :cpack_gen:`CPack NSIS Generator` gained a new
  158. :variable:`CPACK_NSIS_EXECUTABLE` variable to specify the ``makensis``
  159. executable to use instead of the default one.
  160. * The :variable:`CPACK_CUSTOM_INSTALL_VARIABLES` variable was added to set
  161. variables in ``cmake_install.cmake`` script invocations made by CPack.
  162. Deprecated and Removed Features
  163. ===============================
  164. * Undocumented :variable:`CMAKE_SYSTEM_NAME` version-stripping behavior has
  165. been removed entirely. If it is set by a ``-D`` flag or by a
  166. :manual:`toolchain file <cmake-toolchains(7)>`, it is left unaltered,
  167. even if it still contains a version number.
  168. Similar :variable:`CMAKE_HOST_SYSTEM_NAME` version-stripping behavior,
  169. also undocumented, has been moved earlier, before :command:`project` or
  170. :command:`enable_language` is called.
  171. * ``ARMClang`` cpu/arch compile and link flags are no longer added
  172. automatically based on the :variable:`CMAKE_SYSTEM_PROCESSOR`
  173. variable or the undocumented ``CMAKE_SYSTEM_ARCH`` variable.
  174. They must be specified explicitly. See policy :policy:`CMP0123`.
  175. Other Changes
  176. =============
  177. * The :command:`find_file`, :command:`find_path`, :command:`find_program`,
  178. and :command:`find_library` commands handle cache variables in the same way
  179. regardless how they are defined. See policy :policy:`CMP0125` for details.
  180. * The :command:`find_file`, :command:`find_path`, :command:`find_program`,
  181. and :command:`find_library` commands gained the option ``NO_CACHE`` to store
  182. find result in normal variable.
  183. * The :command:`foreach` command now isolates loop variables in the loop scope.
  184. See policy :policy:`CMP0124` for details.
  185. * The :command:`list` command's ``GET``, ``INSERT``, ``SUBLIST``, and
  186. ``REMOVE_AT`` subcommands now error with invalid (i.e., non-integer) values
  187. are given as any of their index arguments based on the setting of policy
  188. :policy:`CMP0121`.
  189. * The :command:`set(CACHE)` command no longer removes a normal variable
  190. of the same name, if any. See policy :policy:`CMP0126`.
  191. * :command:`target_link_libraries` calls referencing object libraries
  192. via the :genex:`TARGET_OBJECTS` generator expression now place the
  193. object files before all libraries on the link line, regardless of
  194. their specified order. See documentation on
  195. :ref:`Linking Object Libraries via \$\<TARGET_OBJECTS\>` for details.
  196. * The :ref:`Ninja Generators` now pass source files and include directories
  197. to the compiler using absolute paths. This makes diagnostic messages and
  198. debug symbols more consistent, and matches the :ref:`Makefile Generators`.
  199. * The :generator:`NMake Makefiles` generator now encodes the generated
  200. makefiles as UTF-8 with a BOM when using ``nmake`` from VS 9 or above.
  201. * The :ref:`Visual Studio Generators` for VS 2010 and above now place
  202. per-source preprocessor definitions after target-wide preprocssor
  203. definitions. This makes VS consistent with the :ref:`Ninja Generators`
  204. and the :ref:`Makefile Generators`.
  205. * The precompiled binaries provided on
  206. `cmake.org <https://cmake.org/download/>`_ now support
  207. ``liblzma`` multi-threading. See the :variable:`CPACK_THREADS` and
  208. :variable:`CPACK_ARCHIVE_THREADS` variables.
  209. Updates
  210. =======
  211. Changes made since CMake 3.21.0 include the following.
  212. 3.21.1
  213. ------
  214. * The :generator:`Visual Studio 17 2022` generator is now based on
  215. "Visual Studio 2022 Preview 2". Previously it was based on "Preview 1.1".