CMake 3.31 Release Notes¶
Changes made since CMake 3.30 include the following.
New Features¶
Presets¶
cmake-presets(7)files may now include comments using the key$commentat any level within the JSON object to provide documentation.cmake-presets(7)files may now request graphviz output using thegraphvizkey in a configure preset.
Generators¶
The Ninja Generators and Makefile Generators now produce a
codegenbuild target. See policyCMP0171. It drives a subset of the build graph sufficient to run custom commands created withadd_custom_command()'s newCODEGENoption.
Command-Line¶
The
cmake --workflowmode now accepts a preset name as the first argument, allowing the simpler command linecmake --workflow <preset>.The
cmake -LR[A][H]option was added to list cache entries whose names match a regular expression.
Compilers¶
The LFortran compiler is now supported with
compiler idLFortran.
Commands¶
The
add_custom_command()command gained aCODEGENoption to mark a custom command's outputs as dependencies of acodegentarget. See policyCMP0171.The
cmake_pkg_config()command was added as an endpoint for using CMake's native pkg-config format parser. The only supported option in this release isEXTRACT, which provides low-level access to the values produced by parsing a pkg-config file. For most users, this is not yet a suitable replacement for theFindPkgConfigmodule.The
file(ARCHIVE_CREATE)command gained aWORKING_DIRECTORYoption to specify a working directory for the archiving process.The
file(MAKE_DIRECTORY)command gained aRESULToption to capture failure in a result variable.The
install(FILES)andinstall(DIRECTORY)commands'TYPEargument gained support for aLIBEXECtype.
Variables¶
The
CMAKE_AIX_SHARED_LIBRARY_ARCHIVEvariable and correspondingAIX_SHARED_LIBRARY_ARCHIVEtarget property were added to create shared libraries on AIX as shared library archives.The
CMAKE_EXPORT_BUILD_DATABASEvariable, a correspondingCMAKE_EXPORT_BUILD_DATABASEenvironment variable, and anEXPORT_BUILD_DATABASEtarget property, were added to enable exporting C++ module compile commands. This is only supported with Ninja Generators.The
CMAKE_HOST_EXECUTABLE_SUFFIXvariable was added to provide the suffix for executable names on the host platform.The
CMAKE_<LANG>_HOST_COMPILER_IDandCMAKE_<LANG>_HOST_COMPILER_VERSIONvariables were added, where<LANG>is eitherCUDAorHIP. They are populated whenCMAKE_<LANG>_COMPILER_IDisNVIDIAto identify NVCC's host compiler.The
CMAKE_<LANG>_STANDARD_LINK_DIRECTORIESvariable was added. Toolchain files can set this variable to control which link library directory paths are always passed to the compiler for the specified language.The
CMAKE_LINK_LIBRARIES_STRATEGYvariable and correspondingLINK_LIBRARIES_STRATEGYtarget property were added to optionally specify the strategy CMake uses to generate link lines.
Properties¶
The
MACOSX_FRAMEWORK_BUNDLE_NAMEtarget property was added to set theCFBundleNamekey in an AppleFRAMEWORK'sInfo.plistfile.The
UNITY_BUILDtarget property now supports theCUDAlanguage.The
VS_FRAMEWORK_REFERENCEStarget property was added to tell Visual Studio Generators to add framework references.
Modules¶
Check modules now support a
CMAKE_REQUIRED_LINK_DIRECTORIESvariable. The following modules gained this support:The
CMakePackageConfigHelpersmodule'sgenerate_apple_platform_selection_file()function gained support for iOS Mac Catalyst.The
GoogleTestmodulegtest_discover_tests()command gained a newDISCOVERY_EXTRA_ARGSkeyword. It allows extra arguments to be appended to the command line when querying for the list of tests.The
FindCUDAToolkitmodule now provides aCUDA::nvml_statictarget.The
FindOpenMPmodule gained support for theCUDAlanguage.
CTest¶
The
ctest_submit()command andctest -T Submitstep now verify TLS server certificates for connections tohttps://URLs by default. See theCTEST_TLS_VERIFYvariable for details.The
ctest_submit()command andctest -T Submitstep now require TLS 1.2 or higher for connections tohttps://URLs by default. See theCTEST_TLS_VERSIONvariable for details.
CPack¶
The
CPack DEB Generatorgained aCPACK_DEBIAN_PACKAGE_MULTIARCHoption to support multi-arch packages.The
CPack IFW Generatorgained the newCPACK_IFW_PACKAGE_PRODUCT_IMAGE_URLSvariable to specify images associated with entries ofCPACK_IFW_PACKAGE_PRODUCT_IMAGES. This feature is available for QtIFW 4.0 and newer.The
CPack RPM Generatorgained support forzstdas aCPACK_RPM_COMPRESSION_TYPEvalue.The
CPackmodule enables per-machine installation by default in theCPack WIX Generator. See policyCMP0172and theCPACK_WIX_INSTALL_SCOPEvariable.
Deprecated and Removed Features¶
Compatibility with versions of CMake older than 3.10 is now deprecated and will be removed from a future version. Calls to
cmake_minimum_required()orcmake_policy()that set the policy version to an older value now issue a deprecation diagnostic.The
CMakeFindFrameworksmodule has been deprecated viaCMP0173. Projects should usefind_library()instead.The
Visual Studio 12 2013generator has been removed.
Other Changes¶
When static libraries on link lines are de-duplicated (by policy
CMP0156), the first occurrence is now kept on all platforms. See policyCMP0179.Empty list elements in the
TEST_LAUNCHERandCROSSCOMPILING_EMULATORtarget properties are now preserved by:The
add_test()command.The
ExternalData_Add_Test()command from theExternalDatamodule.The
gtest_add_tests()andgtest_discover_tests()commands from theGoogleTestmodule. Empty list elements after theEXTRA_ARGSkeyword of these two commands are also now preserved.
See policy
CMP0178.The
execute_process()command'sENCODINGoption, meaningful on Windows, now defaults toUTF-8. See policyCMP0176.The
file(DOWNLOAD)andfile(UPLOAD)commands now verify TLS server certificates for connections tohttps://URLs by default. See theCMAKE_TLS_VERIFYvariable for details. This change was made without a policy so that users are protected even when building projects that have not been updated. Users may set theCMAKE_TLS_VERIFYenvironment variable to0to restore the old default.The
file(DOWNLOAD)andfile(UPLOAD)commands now require TLS 1.2 or higher for connections tohttps://URLs by default. See theCMAKE_TLS_VERSIONvariable for details.The
file(GET_RUNTIME_DEPENDENCIES)command was updated to more closely match the dynamic loader's behavior on Linux.The
install()command'sDESTINATIONarguments are now normalized, with the exception ofINCLUDES DESTINATIONarguments ininstall(TARGETS). See policyCMP0177.The
project()command now always sets<PROJECT-NAME>_SOURCE_DIR,<PROJECT-NAME>_BINARY_DIR, and<PROJECT-NAME>_IS_TOP_LEVELas both normal variables and cache entries. See policyCMP0180.The
cmake_parse_arguments(PARSE_ARGV)command now defines a variable for an empty string after a single-value keyword. See policyCMP0174.