1 CMake 3.21 Release Notes
2 ************************
8 Changes made since CMake 3.20 include the following.
16 * :manual:`cmake-presets(7)` gained support for specifying the install prefix
17 in a configure preset.
19 * :manual:`cmake-presets(7)` gained support for conditional enabling of presets.
21 * :manual:`cmake-presets(7)` gained support for a ``${hostSystemName}`` macro.
23 * :manual:`cmake-presets(7)` gained support for omitting the ``generator`` and
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.
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.
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.
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.
49 * Source file extensions ``.ixx`` and ``.cppm`` are now treated as C++.
54 * :manual:`cmake(1)` gained the ``--install-prefix <dir>``
55 command-line option to specify the location of the install prefix.
57 * :manual:`cmake(1)` gained the ``--toolchain <path/to/file>``
58 command-line option to specify a toolchain file.
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`.
64 * Messages printed to a terminal now may be colored by message type.
69 * The Fujitsu compiler is now supported using compiler id ``Fujitsu``
70 in traditional (``Trad``) mode, and compiler id ``FujitsuClang``
76 * CMake now supports the MSYS runtime environment, much like CYGWIN.
81 * The :manual:`cmake-file-api(7)` "codemodel" version 2 ``version`` field
82 has been updated to 2.3.
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`
92 * The :command:`add_custom_command` command ``DEPFILE`` option:
95 :manual:`generator expressions <cmake-generator-expressions(7)>`,
97 * is now supported by :ref:`Visual Studio Generators` for VS 2012
100 * is now supported by the :generator:`Xcode` generator.
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.
106 * The :command:`build_command` command gained a ``PARALLEL_LEVEL`` option.
108 * The :command:`file(COPY_FILE)` command was added to copy a single file.
110 * The :command:`file(GET_RUNTIME_DEPENDENCIES)` command gained new
111 ``POST_INCLUDE_FILES`` and ``POST_EXCLUDE_FILES`` arguments.
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.
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.
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.
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)`.
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)`.
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.
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.
143 * The :envvar:`CMAKE_TOOLCHAIN_FILE` environment variable was added to
144 provide a default value for the :variable:`CMAKE_TOOLCHAIN_FILE` variable.
149 * The :prop_dir:`IMPORTED_TARGETS` directory property was added to
150 get a list of :ref:`Imported Targets` created in the current
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>`
165 * The :module:`FindBLAS` and :module:`FindLAPACK` modules learned to support
166 the serial ``Fujitsu_SSL2`` and parallel ``Fujitsu_SSL2BLAMP`` libraries.
168 * The :module:`FindDevIL` module now provides imported targets.
170 * The :module:`FindIconv` module now has version support.
172 * The :module:`FindIntl` module now has version support.
174 * The :module:`FindMPI` module learned to support ``Fujitsu`` and
175 ``FujitsuClang`` in both host and cross compiling modes.
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.
181 * The :module:`FindOpenMP` module learned to support ``Fujitsu`` and
184 * The :module:`FindVulkan` module gained imported targets
185 ``Vulkan::Headers`` and ``Vulkan::glslangValidator``.
187 * The :module:`UseJava` module command ``add_jar`` gained a ``RESOURCES``
188 option to allow explicit naming of resources with non-optional namespace.
190 * The :module:`UseSWIG` module use now standard library naming conventions
191 for the ``CSharp`` language. See policy :policy:`CMP0122`.
193 * The :module:`UseSWIG` module now supports using the ``swig`` tool to
194 generate implicit dependencies with the :generator:`Xcode` generator.
196 Generator Expressions
197 ---------------------
199 * A new :genex:`TARGET_RUNTIME_DLLS` generator expression was added.
204 * :manual:`ctest(1)` gained documentation for its ability to capture
205 :ref:`Additional Test Measurements`.
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.
213 * :manual:`ctest(1)` gained a ``--output-junit`` option to write test results
216 * The :command:`ctest_build` command gained a ``PARALLEL_LEVEL`` option.
221 * The :cpack_gen:`CPack DragNDrop Generator` gained option
222 :variable:`CPACK_DMG_FILESYSTEM` to control the ``.dmg`` filesystem.
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.
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.
233 * The :variable:`CPACK_CUSTOM_INSTALL_VARIABLES` variable was added to set
234 variables in ``cmake_install.cmake`` script invocations made by CPack.
236 Deprecated and Removed Features
237 ===============================
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.
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`.
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.
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.
263 * The :command:`foreach` command now isolates loop variables in the loop scope.
264 See policy :policy:`CMP0124` for details.
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
271 * The :command:`set(CACHE)` command no longer removes a normal variable
272 of the same name, if any. See policy :policy:`CMP0126`.
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.
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`.
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.
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`.
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.
300 Changes made since CMake 3.21.0 include the following.
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".
311 * ``CUDA`` targets with :prop_tgt:`CUDA_SEPARABLE_COMPILATION` enabled are now
312 correctly generated in non-root directories.
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".
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".
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:
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.
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.