# CMake 3.21.0 available for download

**URL:** https://discourse.cmake.org/t/cmake-3-21-0-available-for-download/3756
**Category:** Announcements
**Created:** [July 14, 2021, 5:11pm UTC](https://discourse.cmake.org/t/cmake-3-21-0-available-for-download/3756 "2021-07-14T17:11:44Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Tom\_Osika](https://discourse.cmake.org/user_avatar/discourse.cmake.org/tom_osika/32/1101_2.png) [@Tom\_Osika](https://discourse.cmake.org/u/Tom_Osika)
#### Post date: [July 14, 2021, 5:11pm UTC](https://discourse.cmake.org/t/cmake-3-21-0-available-for-download/3756/1 "2021-07-14T17:11:44Z")

</div>

I am happy to announce that CMake 3.21.0 is now available for download at:  
[https://cmake.org/download/](https://cmake.org/download/)

Documentation is available at:  
[https://cmake.org/cmake/help/v3.21](https://cmake.org/cmake/help/v3.21)

Release notes appear below and are also published at  
[https://cmake.org/cmake/help/v3.21/release/3.21.html](https://cmake.org/cmake/help/v3.21/release/3.21.html)

Some of the more significant changes in CMake 3.21 are:

- CMake learned to support “HIP” as a first-class language that can be  
enabled via the “project()” and “enable\_language()” commands.

- The “Visual Studio 17 2022” generator was added. This is  
experimental and based on “Visual Studio 2022 Preview 1.1” because  
this version of VS has not been released.

- The Makefile Generators and the “Ninja” generator learned to add  
linker launcher tools along with the linker for “C”, “CXX”, “OBJC”,  
and “OBJCXX” languages. See the “CMAKE\_\_LINKER\_LAUNCHER”  
variable and “\_LINKER\_LAUNCHER” target property for details.

- “C\_STANDARD”, “OBJC\_STANDARD”, and the “Compile Features”  
functionality gained support for C17 and C23.

- “cmake(1)” gained the “–toolchain \<path/to/file\>” command-line  
option to specify a toolchain file.

- Messages printed to a terminal now may be colored by message type.

- The Fujitsu compiler is now supported using compiler id “Fujitsu” in  
traditional (“Trad”) mode, and compiler id “FujitsuClang” in “Clang”  
mode.

- The “add\_custom\_command()” command “DEPFILE” option may now use  
“generator expressions”, is now supported by Visual Studio Generators  
for VS 2012 and above, and is now supported by the “Xcode” generator.

- The “add\_custom\_command(TARGET)” command (for Build Events) gained  
support for resolving target-dependent generator expressions.

- The “install(TARGETS)” command gained new “RUNTIME\_DEPENDENCIES” and  
“RUNTIME\_DEPENDENCY\_SET” arguments, which can be used to install  
runtime dependencies using “file(GET\_RUNTIME\_DEPENDENCIES)”.

- A new “TARGET\_RUNTIME\_DLLS” generator expression was added.

- “ctest(1)” gained a “–output-junit” option to write test results to  
a JUnit XML file.

- The “ctest\_build()” command gained a “PARALLEL\_LEVEL” option.

- “ARMClang” cpu/arch compile and link flags are no longer added  
automatically based on the “CMAKE\_SYSTEM\_PROCESSOR” variable or the  
undocumented “CMAKE\_SYSTEM\_ARCH” variable. They must be specified  
explicitly. See policy “CMP0123”.

- The “foreach()” command now isolates loop variables in the loop  
scope. See policy “CMP0124” for details.

CMake 3.21 Release Notes

* * *

Changes made since CMake 3.20 include the following.

# New Features

## Presets

- “cmake-presets(7)” gained support for specifying the install prefix  
in a configure preset.

- “cmake-presets(7)” gained support for conditional enabling of  
presets.

- “cmake-presets(7)” gained support for a “${hostSystemName}” macro.

- “cmake-presets(7)” gained support for omitting the “generator” and  
“binaryDir” fields.

## Generators

- The Makefile Generators and the “Ninja” generator learned to add  
linker launcher tools along with the linker for “C”, “CXX”, “OBJC”,  
and “OBJCXX” languages. See the “CMAKE\_\_LINKER\_LAUNCHER”  
variable and “\_LINKER\_LAUNCHER” target property for details.

- The “Visual Studio 17 2022” generator was added. This is  
experimental and based on “Visual Studio 2022 Preview 1.1” because  
this version of VS has not been released.

## Languages

- CMake learned to support “HIP” as a first-class language that can be  
enabled via the “project()” and “enable\_language()” commands.

- “C\_STANDARD”, “OBJC\_STANDARD”, and the “Compile Features”  
functionality gained support for C17 and C23.

- Source file extensions “.ixx” and “.cppm” are now treated as C++.

## Command-Line

- “cmake(1)” gained the “–install-prefix ” command-line option  
to specify the location of the install prefix.

- “cmake(1)” gained the “–toolchain \<path/to/file\>” command-line  
option to specify a toolchain file.

- “cmake(1)” “-E capabilities” output, for some generators, may now  
contain a “supportedPlatforms” field listing platforms known to be  
supported in “CMAKE\_GENERATOR\_PLATFORM”.

- Messages printed to a terminal now may be colored by message type.

## Compilers

- The Fujitsu compiler is now supported using compiler id “Fujitsu” in  
traditional (“Trad”) mode, and compiler id “FujitsuClang” in “Clang”  
mode.

## Platforms

- CMake now supports the MSYS runtime environment, much like CYGWIN.

## File-Based API

- The “cmake-file-api(7)” “codemodel” version 2 “version” field has  
been updated to 2.3.

- The “cmake-file-api(7)” “codemodel” version 2 gained a new  
“directory” object containing directory-level information. This  
includes a list of installers generated by the “install()” command.

## Commands

- The “add\_custom\_command()” command “DEPFILE” option may now use  
“generator expressions”, is now supported by Visual Studio Generators  
for VS 2012 and above, and is now supported by the “Xcode” generator.

- The “add\_custom\_command(TARGET)” command (for Build Events) gained  
support for resolving target-dependent generator expressions.

- The “build\_command()” command gained a “PARALLEL\_LEVEL” option.

- The “file(COPY\_FILE)” command was added to copy a single file.

- The “file(GET\_RUNTIME\_DEPENDENCIES)” command gained new  
“POST\_INCLUDE\_FILES” and “POST\_EXCLUDE\_FILES” arguments.

- The “file(REAL\_PATH)” command gained the option “EXPAND\_TILDE” to  
replace any leading tilde with the path to the user’s home  
directory.

- The “file(RENAME)” command learned to optionally capture failure in  
a result variable. It also gained a “NO\_REPLACE” option to fail if  
the destination exists.

- The “install()” command gained a new “IMPORTED\_RUNTIME\_ARTIFACTS”  
mode, which can be used to install the runtime artifacts of imported  
targets.

- The “install()” command gained a new “RUNTIME\_DEPENDENCY\_SET” mode,  
which can be used to install runtime dependencies using  
“file(GET\_RUNTIME\_DEPENDENCIES)”.

- The “install(TARGETS)” command gained new “RUNTIME\_DEPENDENCIES” and  
“RUNTIME\_DEPENDENCY\_SET” arguments, which can be used to install  
runtime dependencies using “file(GET\_RUNTIME\_DEPENDENCIES)”.

- The “install(SCRIPT|CODE)” command supports a new option  
“ALL\_COMPONENTS” which allows the corresponding code to run for  
every component of a per component installation.

- The “project()” command now sets variables “PROJECT\_IS\_TOP\_LEVEL”  
and “\_IS\_TOP\_LEVEL” to indicate whether it was called  
in a top-level “CMakeLists.txt” file.

## Variables

- The “CMAKE\_TOOLCHAIN\_FILE” environment variable was added to provide  
a default value for the “CMAKE\_TOOLCHAIN\_FILE” variable.

## Properties

- The “IMPORTED\_TARGETS” directory property was added to get a list of  
Imported Targets created in the current directory.

- The “XCODE\_EMBED\_APP\_EXTENSIONS” target property was added to tell  
the “Xcode” generator to embed app extensions such as iMessage  
sticker packs. Aspects of the embedding can be customized with the  
“XCODE\_EMBED\_APP\_EXTENSIONS\_PATH”,  
“XCODE\_EMBED\_APP\_EXTENSIONS\_CODE\_SIGN\_ON\_COPY” and  
“XCODE\_EMBED\_APP\_EXTENSIONS\_REMOVE\_HEADERS\_ON\_COPY” properties.

## Modules

- The “FindBLAS” and “FindLAPACK” modules learned to support the  
serial “Fujitsu\_SSL2” and parallel “Fujitsu\_SSL2BLAMP” libraries.

- The “FindDevIL” module now provides imported targets.

- The “FindIconv” module now has version support.

- The “FindIntl” module now has version support.

- The “FindMPI” module learned to support “Fujitsu” and “FujitsuClang”  
in both host and cross compiling modes.

- The “FindMsys” module was added to find MSYS installations. Like  
“FindCygwin”, it is used automatically by some other find modules to  
locate UNIX-style tools on Windows.

- The “FindOpenMP” module learned to support “Fujitsu” and  
“FujitsuClang”.

- The “FindVulkan” module gained imported targets “Vulkan::Headers”  
and “Vulkan::glslangValidator”.

- The “UseJava” module command “add\_jar” gained a “RESOURCES” option  
to allow explicit naming of resources with non-optional namespace.

- The “UseSWIG” module use now standard library naming conventions for  
the “CSharp” language. See policy “CMP0122”.

- The “UseSWIG” module now supports using the “swig” tool to generate  
implicit dependencies with the “Xcode” generator.

## Generator Expressions

- A new “TARGET\_RUNTIME\_DLLS” generator expression was added.

## CTest

- “ctest(1)” gained documentation for its ability to capture  
Additional Test Measurements.

- “ctest(1)” learned to recognize files attached to a test at run  
time. Previously it was only possible to attach files to tests at  
configure time by using the “ATTACHED\_FILES” or  
“ATTACHED\_FILES\_ON\_FAIL” test properties. See Additional Test  
Measurements for more information.

- “ctest(1)” gained a “–output-junit” option to write test results to  
a JUnit XML file.

- The “ctest\_build()” command gained a “PARALLEL\_LEVEL” option.

## CPack

- The “CPack DragNDrop Generator” gained option “CPACK\_DMG\_FILESYSTEM”  
to control the “.dmg” filesystem.

- The “CPack IFW Generator” now supports hyphens in names given to  
“cpack\_ifw\_configure\_component()” or  
“cpack\_ifw\_configure\_component\_group()” as “DEPENDS” or  
“DEPENDENCIES” arguments. This requires QtIFW 3.1 or later.

- The “CPack NSIS Generator” gained a new “CPACK\_NSIS\_EXECUTABLE”  
variable to specify the “makensis” executable to use instead of the  
default one.

- The “CPACK\_CUSTOM\_INSTALL\_VARIABLES” variable was added to set  
variables in “cmake\_install.cmake” script invocations made by CPack.

# Deprecated and Removed Features

- Undocumented “CMAKE\_SYSTEM\_NAME” version-stripping behavior has been  
removed entirely. If it is set by a “-D” flag or by a “toolchain  
file”, it is left unaltered, even if it still contains a version  
number. Similar “CMAKE\_HOST\_SYSTEM\_NAME” version-stripping behavior,  
also undocumented, has been moved earlier, before “project()” or  
“enable\_language()” is called.

- “ARMClang” cpu/arch compile and link flags are no longer added  
automatically based on the “CMAKE\_SYSTEM\_PROCESSOR” variable or the  
undocumented “CMAKE\_SYSTEM\_ARCH” variable. They must be specified  
explicitly. See policy “CMP0123”.

# Other Changes

- The “find\_file()”, “find\_path()”, “find\_program()”, and  
“find\_library()” commands handle cache variables in the same way  
regardless how they are defined. See policy “CMP0125” for details.

- The “find\_file()”, “find\_path()”, “find\_program()”, and  
“find\_library()” commands gained the option “NO\_CACHE” to store find  
result in normal variable.

- The “foreach()” command now isolates loop variables in the loop  
scope. See policy “CMP0124” for details.

- The “list()” command’s “GET”, “INSERT”, “SUBLIST”, and “REMOVE\_AT”  
subcommands now error with invalid (i.e., non-integer) values are  
given as any of their index arguments based on the setting of policy  
“CMP0121”.

- The “set(CACHE)” command no longer removes a normal variable of the  
same name, if any. See policy “CMP0126”.

- “target\_link\_libraries()” calls referencing object libraries via the  
“TARGET\_OBJECTS” generator expression now place the object files  
before all libraries on the link line, regardless of their specified  
order. See documentation on Linking Object Libraries via  
$\<TARGET\_OBJECTS\> for details.

- The Ninja Generators now pass source files and include directories  
to the compiler using absolute paths. This makes diagnostic  
messages and debug symbols more consistent, and matches the Makefile  
Generators.

- The “NMake Makefiles” generator now encodes the generated makefiles  
as UTF-8 with a BOM when using “nmake” from VS 9 or above.

- The Visual Studio Generators for VS 2010 and above now place per-  
source preprocessor definitions after target-wide preprocssor  
definitions. This makes VS consistent with the Ninja Generators and  
the Makefile Generators.

- The precompiled binaries provided on [cmake.org](http://cmake.org) now support “liblzma”  
multi-threading. See the “CPACK\_THREADS” and  
“CPACK\_ARCHIVE\_THREADS” variables.

* * *

Changes made since CMake 3.21.0-rc3:

Alex Turbov (1):

- CPack/DEB: Avoid overriding user-provided `postinst` and `postrm`

Brad King (6):

- FindJPEG: Revert “Search for ‘turbojpeg’ and ‘turbojpeg-static’ too”
- Tests: Fix RunCMake.try\_compile C/CXX standards with IntelLLVM MSVC mode
- Find{BLAS,LAPACK}: Avoid clobbering results when no vendor is requested
- ci: Verify that Intel MKL is found when it is the only BLAS/LAPACK
- Help: Clarify ‘cmake --build’ signature alternatives
- CMake 3.21.0

Kyle Edwards (1):

- file(GET\_RUNTIME\_DEPENDENCIES): Check architecture of dependencies

Lingkai Dong (1):

- ARMClang: Fix regression in check for working compiler

Raul Tambre (1):

- CMakeCCompilerId: Fix C standard detection in Clang and IntelLLVM MSVC mode

Sérgio Martins (1):

- Help: Fix preset example cmakeMinimumRequired

---

<div class="post-metadata">

### Author: ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)
#### Post date: [July 14, 2021, 8:43pm UTC](https://discourse.cmake.org/t/cmake-3-21-0-available-for-download/3756/2 "2021-07-14T20:43:22Z")

</div>

Key user-facing upgrades:

- `cmake --install-prefix ~/my` option as a friendly alternative to `cmake -DCMAKE_INSTALL_PREFIX=~/my`
- Presets no longer requiring `generator`

---

<div class="post-metadata">

### Author: ![ferdnyc](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ferdnyc/32/267_2.png) [@ferdnyc](https://discourse.cmake.org/u/ferdnyc)
#### Post date: [July 22, 2021, 10:52am UTC](https://discourse.cmake.org/t/cmake-3-21-0-available-for-download/3756/3 "2021-07-22T10:52:15Z")

</div>

> [@Tom\_Osika](#):
>
> ## Generator Expressions
> 
> - A new “TARGET\_RUNTIME\_DLLS” generator expression was added.

Is it maybe worth mentioning that (IIUC) the “DLLS” in that expression is literal, and it will only have any contents when building on a Windows platform? (IOW, not all shared libraries are DLLS, only `.dll` files are DLLS.)

The other changes, to the `RUNTIME_DEPENDENCIES`-type properties/expressions, are cross-platform.

---

<div class="post-metadata">

### Author: ![DanielaE](https://discourse.cmake.org/user_avatar/discourse.cmake.org/danielae/32/1659_2.png) [@DanielaE](https://discourse.cmake.org/u/DanielaE)
#### Post date: [July 23, 2021, 5:12pm UTC](https://discourse.cmake.org/t/cmake-3-21-0-available-for-download/3756/4 "2021-07-23T17:12:47Z")

</div>

The VisualStudio generators 2019 and 2022 actively remove compiler option `/interface`. This broke the CI of the {fmt} library: [https://github.com/fmtlib/fmt/pull/2432#issuecomment-885717118](https://github.com/fmtlib/fmt/pull/2432#issuecomment-885717118). Without this option, no module interface unit can be build. Even worse: the generated compiler options make no sense anymore. 😱  
The Ninja generator doesn’t have this problem. The only visible change in the generated `ninja.build` is a switch from relative paths to full, absolute paths.

With 3.20 everything was fine.

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [July 26, 2021, 2:36pm UTC](https://discourse.cmake.org/t/cmake-3-21-0-available-for-download/3756/5 "2021-07-26T14:36:22Z")

</div>

I’ve opened [CMake Issue 22477](https://gitlab.kitware.com/cmake/cmake/-/issues/22477) for the `/interface` option, thanks. Please follow that for updates.

---

<div class="post-metadata">

### Author: ![DanielaE](https://discourse.cmake.org/user_avatar/discourse.cmake.org/danielae/32/1659_2.png) [@DanielaE](https://discourse.cmake.org/u/DanielaE)
#### Post date: [August 9, 2021, 1:15pm UTC](https://discourse.cmake.org/t/cmake-3-21-0-available-for-download/3756/6 "2021-08-09T13:15:45Z")

</div>

Brad,

thanks a lot for your attention - much appreciated!  
I’ve updated to 3.21.1 now and can confirm that the `/interface` compiler option is present now. Alas, it looks like the missing other half of modules support has slipped through unit testing. As shown in [issue 22474](https://gitlab.kitware.com/cmake/cmake/-/issues/22474), the module reference requires `/reference $module-name=$path-to-BMI` in the `INTERFACE` of `target_compile_options()`. The `/reference` introducer is still swallowed by the generator, leaving `$module-name=$path-to-BMI` as a malformed command line part.

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [August 9, 2021, 1:21pm UTC](https://discourse.cmake.org/t/cmake-3-21-0-available-for-download/3756/7 "2021-08-09T13:21:42Z")

</div>

if `/reference $module-name=$path-to-BMI` must be kept together, please use `SHELL:` prefix to avoid deduplication processing:

```cmake
target_compile_options(mytarget INTERFACE "SHELL:/reference $module-name=$path-to-BMI")

```

---

<div class="post-metadata">

### Author: ![DanielaE](https://discourse.cmake.org/user_avatar/discourse.cmake.org/danielae/32/1659_2.png) [@DanielaE](https://discourse.cmake.org/u/DanielaE)
#### Post date: [August 10, 2021, 10:59am UTC](https://discourse.cmake.org/t/cmake-3-21-0-available-for-download/3756/8 "2021-08-10T10:59:45Z")

</div>

Thanks for the tip, but this doesn’t change a bit. The generator still puts

`<AdditionalOptions>%(AdditionalOptions)fmt=Z:/fmt/build/test/test-module.ifc</AdditionalOptions>`

into the vcxproj-file instead of

`<AdditionalOptions>%(AdditionalOptions)/reference fmt=Z:/fmt/build/test/test-module.ifc</AdditionalOptions>`

Instead of generating `AdditionalOptions` it could transform all module-related options into the corresponding MSBuild entities.

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [August 10, 2021, 2:22pm UTC](https://discourse.cmake.org/t/cmake-3-21-0-available-for-download/3756/9 "2021-08-10T14:22:11Z")

</div>

> [@DanielaE](#):
>
> Instead of generating `AdditionalOptions` it could transform all module-related options into the corresponding MSBuild entities.

That’s what CMake’s Visual Studio generators try to do in general. It is the attempt to do that mapping that causes the `/reference` flag to be removed.

This is out of scope for discussion under a release announcement. If you found a regression in the release, please open an [issue](https://gitlab.kitware.com/cmake/cmake/-/issues) to report it.

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [August 10, 2021, 2:34pm UTC](https://discourse.cmake.org/t/cmake-3-21-0-available-for-download/3756/10 "2021-08-10T14:34:03Z")

</div>

I’ve opened [CMake Issue 22530](https://gitlab.kitware.com/cmake/cmake/-/issues/22530) for the `/reference` flag. Please follow that issue for updates.
