3.21.rst 11 KB

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