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