CMake 4.5 Release Notes¶
Changes made since CMake 4.4 include the following.
New Features¶
Diagnostics¶
The
CMD_NON_TARGET_DIRECTIVEdiagnostic category was added to diagnose commands that affect the directory scope when comparable target-specific commands exist. The use of such directives is discouraged. This diagnostic may be controlled with the-Wnon-target-directivecommand-line option, thenonTargetDirectivefield in aCMake Presetswarningsobject, or thecmake_diagnostic()command.The
CMD_STRICTdiagnostic category was added to control diagnostics regarding allowed but discouraged usage as a group. This diagnostic may be controlled with the-Wstrictcommand-line option, thestrictfield in aCMake Presetswarningsobject, or thecmake_diagnostic()command.
Presets¶
cmake-presets(7)files now support schema version 13.cmake-presets(7)gained the${configurePresetName}macro to expand to the name of the configure preset associated with the preset being evaluated. It is available for configure, build, test, and package presets, but not for workflow presets.
File-Based API¶
The
cmake-file-api(7)"codemodel" version 2versionfield has been updated to 2.12.The
cmake-file-api(7)"codemodel" version 2 "target" object gained a newinterfaceIncludesarray field.
Instrumentation¶
The
cmake-instrumentation(7)data version has been updated to 1.2.cmake-instrumentation(7)now records an overallcmakeBuildsnippet even when acmake --buildinvocation is interrupted by the user (for example with Ctrl+C). The snippet includes a newinterruptSignalfield, recording the signal that interrupted the build, so that consumers can distinguish an interrupted build from one that ran to completion.cmake-instrumentation(7)now records an overallcmakeInstallsnippet, marked with the sameinterruptSignalfield, when acmake --installinvocation is interrupted by the user.cmake-instrumentation(7)now records an overallctestsnippet, marked with the sameinterruptSignalfield, when actest(1)invocation is interrupted by the user. On interrupt CTest stops scheduling further tests and preserves its checkpoint file so that a laterctest -Fcan resume the interrupted test set.
Generators¶
The Ninja Generators, Makefile Generators, and
FASTBuildgenerator now provideinstall_prep/allandinstall_prep/<component>convenience build targets by default. TheCMAKE_SKIP_INSTALL_PREP_TARGETSvariable may be enabled to skip generating them. These targets build all known build dependencies for an installation that does not select a component, or for the named install component, respectively. This includes targets that produce installed C++ module BMIs, module export metadata, or generated files. See Install Preparation Targets.The
FASTBuildgenerator and the Makefile Generators now providetest_prep/<test-name>andtest_prep/allconvenience build targets by default. TheCMAKE_SKIP_TEST_PREP_TARGETSvariable may be enabled to skip generating them. These targets build the dependencies of tests added byadd_test(), including those listed with theBUILD_DEPENDSkeyword. See Test Preparation Targets.The Ninja Generators now provide
test_prep/<test-name>andtest_prep/allconvenience build targets build targets by default. TheCMAKE_SKIP_TEST_PREP_TARGETSvariable may be enabled to skip generating them. These targets were previously generated only ifCMAKE_TEST_BUILD_DEPENDSwas enabled. See Test Preparation Targets.Makefile Generators and Ninja Generators gained support for adding a linker launcher with
CUDAandHIP. See theCMAKE_<LANG>_LINKER_LAUNCHERvariable and<LANG>_LINKER_LAUNCHERtarget property for details.
Languages¶
import stdis now available for all C++ 20 and later code withCXX_SCAN_FOR_MODULESenabled.
Compilers¶
The open-source DPC++ compiler, version 7.0 and newer, is now supported with
compiler idDPClangfor languagesCandCXX.
Command-Line¶
The
cmake -E capabilitiesoutput now includes aninstrumentationobject reporting the supported instrumentation API version and the latest supported data version.The
cmake --list-presetsoption gained*-definedvalues that list all non-hidden presets of the corresponding type and explain why unavailable presets cannot be used. Thedefinedvalue is an alias forconfigure-defined, whileall-definedselects every type. Build, test, and package presets whose configure preset is unavailable are now considered unavailable too.The
cmake --build --list-presets=defined,ctest --list-presets=defined, andcpack --list-presets=definedoptions were added to list all defined build, test, and package presets, respectively.The
cmake --workflow --list-presets=definedoption was added to provide the same availability information for all defined workflow presets and their steps.
Commands¶
The
add_custom_rule()command was added to allow the definition of pattern rules.The
add_dependencies()command now accepts Alias Targets. Dependencies are added to the target the alias references.The
discover_tests()command gained aBUILD_DEPENDSargument to support the--out-of-datebehavior ofctest(1).The
cmake_language(PRINT_PROPERTIES)command was added to print CMake entities' properties in human-readable form for debugging.The
cmake_language(PRINT_TARGETS)command was added to print the targets that currently exist in human-readable form for debugging.The
cmake_language(PRINT_VARIABLES)command was added to print variables and their values in human-readable form for debugging.The
file(ARCHIVE_CREATE)command gained aPATTERNS_EXCLUDEoption to omit files and directories matching the given patterns from the created archive.The
file(ARCHIVE_EXTRACT)command gained aPATTERNS_EXCLUDEoption to omit archive entries matching the given patterns from being extracted or listed.The
file(GET_RUNTIME_DEPENDENCIES)command is now implemented on FreeBSD.The
find_package()command now supports importing Common Package Specification executable components.The
function()command now sets theARGNCvariable, which holds the number of arguments past the last expected argument.The
if()command gained aPATH_IS_PREFIXoperator to test whether one path is a prefix of another without accessing the filesystem. See policyCMP0222.The
if()command gained aRULEoperator to check if a rule exists.The
install()andexport()commands now accept Alias Targets. The commands operate on the underlying aliased target.The
install(SBOM)andexport(SBOM)commands were added to generate Software Bill of Materials (SBOM) files.The
install(TARGETS)command no longer requires aLIBRARY DESTINATIONfor Module Libraries. When no destination is given, a module library is installed to the defaultRUNTIMEdestination on DLL platforms and to the defaultLIBRARYdestination on other platforms.The
install(TARGETS)command gained aRUNTIME_DEPENDENCY_TARGETSoption to install runtime artifacts of non-imported shared libraries from the same build that the named targets link to. UnlikeRUNTIME_DEPENDENCIES, this uses CMake target graph information rather thanfile(GET_RUNTIME_DEPENDENCIES). The option cannot be used withEXPORTand may only install runtime artifacts.The
install()command'sFILES,PROGRAMS,DIRECTORY,SCRIPT, andCODEsignatures gained aBUILD_DEPENDSoption to specify targets or files needed to prepare files or run installation code. See Install Preparation Targets.The
math()command gained newINCREMENTandDECREMENTmodes.The
project()andenable_language()commands, when called in subdirectories, now propagate support for enabled languages to all ancestor scopes up to the top-level directory, including through enclosingblock()andfunction()scopes. See policyCMP0220.The
set_property()andget_property()commands now support RULE properties.The
set_property()andset_target_properties()commands now accept Alias Targets. Properties are set on the target which the alias references.The
string(JSON)command gained anARRAY_SPLITmode that splits a JSON array into a list of its elements with a single parse, enabling linear-time array iteration instead of re-parsing the whole JSON string for each element.The
target_compile_definitions(),target_compile_features(),target_compile_options(),target_include_directories(),target_link_directories(),target_link_libraries(),target_link_options(),target_precompile_headers(), andtarget_sources()commands now accept Alias Targets. The command operates on the target the alias references.
File Sets¶
Common Package Specification import by
find_package(), and export byinstall(PACKAGE_INFO)andexport(PACKAGE_INFO), now support header file sets.The
source_group()command gained support for file sets.The
FILE_SET_TYPES,FILE_SETS_<TYPE>, andINTERFACE_FILE_SETS_<TYPE>target properties were added to get information about file sets attached to the target.The
LANGUAGEfile set property was added to select the compile language for members of aSOURCESfile set without modifying theirLANGUAGEsource file property.The
SOURCE_GROUPfile set property andSOURCE_GROUPsource file property were added to provide a fine grain control over the grouping of sources.
Variables¶
The
CMAKE_CXX_STDLIB_MODULES_JSONvariable was added to set the path to theimport stdmetadata file for the standard library rather than using the compiler to discover its location.The
CMAKE_INSTALL_SBOM_FORMATSvariable was added to enable Software Bill of Materials (SBOM) generation.The
CMAKE_TEST_BUILD_DEPENDSvariable is no longer honored. Test preparation targets are now enabled by default. TheCMAKE_SKIP_TEST_PREP_TARGETSvariable may be enabled to skip generating them.
Environment Variables¶
The
CMAKE_SYSTEM_ENVIRONMENT_IDenvironment variable was added to hint tocmake(1)when--freshmay be necessary, along withCMAKE_SYSTEM_ENVIRONMENT_ACTIONto control what happens whenCMAKE_SYSTEM_ENVIRONMENT_IDchanges.
Properties¶
The
CMAKE_COMPILE_WRAPPER_<NAME>andCMAKE_LINK_WRAPPER_<NAME>global properties were added alongside theCOMPILE_WRAPPERS,LINK_WRAPPERS,INTERFACE_COMPILE_WRAPPERS, andINTERFACE_LINK_WRAPPERStarget properties. Together, for the Makefile Generators and Ninja Generators, they support wrapping compile and link commands for a given target or its consumers with arbitrary command lines.The
CMAKE_TEST_BUILD_DEPENDSdirectory property was added to support directory-scoped build time dependencies for tests.The
Fortran_BUILDING_INTRINSIC_MODULEStarget property is now honored by the Ninja Generators. Previously it was only honored by the Makefile Generators.The
Swift_MODULE_NAMEtarget property is now honored by theXcodegenerator. See policyCMP0226.The
TEST_INCLUDE_FILESandTEST_INCLUDE_FILEdirectory properties now supportgenerator expressionsin the include path. On multi-config generators a$<CONFIG>-parameterized path can select a different script per configuration.The
XCODE_EMBED_<type>target property now supportsgenerator expressions. Because Xcode shares one copy-files build phase across all configurations, an expression whose result depends on the configuration is rejected with an error.
Modules¶
The
ExternalProjectmodule'sExternalProject_Add()command now setsCMAKE_INSTALL_PREFIXto the external project'sINSTALL_DIRin its default configure command, so a CMake external project installs into the prefix the module reserves for it rather than the built-in default (e.g./usr/local). A caller-supplied prefix still takes precedence. See policyCMP0225.The
FindCUDAToolkitmodule now createsCUDAToolkit::namespace targets and changes the existingCUDA::namespace targets to be alias targets.The
FindDoxygenmoduledoxygen_add_docs()command gained aUSES_TERMINALoption to give the Doxygen command direct access to the terminal during the build.The
FindPython,FindPython2, andFindPython3modules gained the possibility to override theCMAKE_CROSSCOMPILING_EMULATORvariable by respectively, the variablesPython_CROSSCOMPILING_EMULATOR,Python2_CROSSCOMPILING_EMULATOR, andPython3_CROSSCOMPILING_EMULATOR.The
FindPython3andFindPythonmodules gained, respectively, the variablePython3_SOSABI_PLATFORMandPython_SOSABI_PLATFORMwhich gives, on some platforms, for the Stable Application Binary Interface, the extension including the platform triplet.
Generator Expressions¶
The
$<ARGS>generator expression was added to convert a semicolon-separated list into a comma-separated list.The
$<DIRECTORY_PROPERTY>generator expression was added to query directory properties.The
$<GLOBAL_PROPERTY>generator expression was added to query global properties.The
LISTgenerator expression'sFILTERandTRANSFORMoperations gained aPREDICATEkeyword that selects items by evaluating an arbitrary generator expression once per item, with$<_0>referring to the current item.FILTERalso gained an explicitREGEXkeyword.The
LISTgenerator expression'sSORToperation gained aCOMPARATORoption that orders items using an arbitrary generator expression evaluated once per comparison, with$<_0>and$<_1>referring to the two items being compared.The
LISTgenerator expression'sTRANSFORMoperation gained anAPPLYaction that evaluates an arbitrary generator expression for each element, with$<_0>referring to the current element.The
$<LINK_LIBRARY:NEEDED_LIBRARY,...>generator expression feature is now supported on Linux with GNU-compatible linkers (GNU ld, gold, LLD, MOLD).The
RULE_PROPERTYgenerator expression was added to query properties of rules created by theadd_custom_rule()command.
Autogen¶
AUTOMOCnow processes C++ module interface and partition units that are members of aFILE_SETof typeCXX_MODULES.mocis run on such units and its generated output is compiled as a module implementation unit of the same module. This requires Qt 6.13 or newer, whosemocsupports C++ module units.AUTOMOCnow has its generatedmocs_compilation.cppscanned for C++ module dependencies under the same conditions as the target's own sources. A header that imports a module may now be processed bymoc.
CTest¶
ctest(1)gained a--out-of-dateoption to run only tests whose recorded build dependencies are newer than the last time the tests ran.ctest(1)now supports job server integration on Windows.The
ctest(1)--show-onlyoption gained ajson-v1-rawformat in which thevaluefor each test property is the original unparsed string value specified in CMake.The
ctest_test()andctest_memcheck()commands gained the ability to accept more than one value for theirINCLUDE_LABELandEXCLUDE_LABELoptions. When multiple regular expressions are given, a test is selected only if each expression matches at least one of the test's labels (i.e. the expressions form anANDrelationship), matching the behavior of repeating thectest --label-regexandctest --label-excludecommand-line options.The
GENERATED_RESOURCE_SPEC_FILEtest property gained support for relative paths.The
FIXTURE_REPEAT_MODEtest property was added to select how a test fixture behaves whenctest(1)repeats tests with its--repeatoption. See policyCMP0224.The
RESOURCE_ERROR_ACTIONtest property andCTEST_RESOURCE_ERROR_ACTIONvariable were added to configure the test behavior in case of insufficient resources.
CPack¶
The
CPack APK Generatorwas added to package Android applications as APK files. It drives the Android SDK build tools directly and does not require Gradle. Maven dependencies, such as the AndroidX libraries, can be downloaded withCPACK_APK_MAVEN_DEPENDENCIES.
Deprecated and Removed Features¶
The
Visual Studio 14 2015generator has been removed.The
CMakePrintHelpersmodule'scmake_print_properties()command is now deprecated in favor ofcmake_language(PRINT_PROPERTIES).The
CMakePrintHelpersmodule'scmake_print_variables()command is now deprecated in favor ofcmake_language(PRINT_VARIABLES).The
install_files(),install_programs(),install_targets(),make_directory(),remove(),subdirs()andwrite_file()commands, which have been deprecated since CMake 3.0, now emit deprecation diagnostics when used.
Other Changes¶
The
cmake --buildcommand now groups the output of each recipe in a parallel build so that concurrent jobs do not interleave, when CMake is the one passing the parallel flag to the build tool (via--parallelorCMAKE_BUILD_PARALLEL_LEVEL) and that tool is GNU Make 4.0 or newer. Request parallelism natively, e.g.cmake --build . -- -j, to opt out and stream output as it is produced.The
cmake --installcommand now reports a non-zero exit code when an install script fails. Previously, a parallel install (enabled by theINSTALL_PARALLELglobal property) always reported success, and a serial install could lose the failure of an earlier component that exited viacmake_language(EXIT)when a later component succeeded.The
cmake_host_system_information()command'sDISTRIB_*queries now read the host os-release by default. See policyCMP0221. A newFROM_SYSROOT <bool>option explicitly enables or disables reading the target os-release fromCMAKE_SYSROOT.The
cmake_path(IS_PREFIX)command and the$<PATH:IS_PREFIX>generator expression no longer treat an empty path as a prefix of every path. Theif()command'sPATH_IS_PREFIXoperator follows the same rule. See policyCMP0223.When CTest build launchers are enabled (see the
CTestUseLaunchersmodule), a build rule that is terminated by a signal is now reported as a build failure. Previously such a rule was reported as success, so a crashed compiler, linker, or custom command could be recorded as a passing build on the dashboard.The
ALIASED_TARGETtarget property is now read-only.The Qt Help (
.qch) rendition of the documentation now carries its own color scheme. Previously it was rendered with layout rules only, because theqthelpbuilder does not generate the color scheme that the HTML documentation uses. A dark variant is shipped alongside it, which help viewers such as Qt Creator use when their own theme is dark.The precompiled macOS binary provided on
cmake.orgnow requires macOS 11 or newer for command-line tools. Thecmake-gui(1)application still requires macOS 12.