3.21.rst 12 KB

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