CMake 4.4 Release Notes

Changes made since CMake 4.3 include the following.

New Features

Diagnostics

  • CMake diagnostic actions are now tracked in a new state type managed by the cmake_diagnostic() command. This replaces the old system which sometimes used variables to manage reporting actions and sometimes did not allow management beyond command-line options and presets. The new system also introduces several new diagnostic categories and significantly reduces the cost of adding additional categories in the future. See the cmake-diagnostics(7) manual for a list of available categories.

  • The CMD_INSTALL_ABSOLUTE_DESTINATION diagnostic category was added to diagnose install() commands that specify an absolute DESTINATION. This diagnostic may be controlled with the -Winstall-absolute-destination command-line option, the installAbsoluteDestination field in a CMake Presets warnings object, or the cmake_diagnostic() command.

Presets

File-Based API

  • The cmake-file-api(7) "codemodel" version 2 object has been updated to 2.11.

  • The cmake-file-api(7) "codemodel" version 2 "target" object's "sources" and "interfaceSources" objects gained new fileSetIndexes fields to support sources belonging to multiple file sets. The fileSetIndex fields are maintained for backwards compatibility only, and users are advised to port to the new fields.

  • The cmake-file-api(7) "codemodel" version 2 "target" object's "sources" object gained a new backtraces field to represent multiple command invocations which associate a single source for a given target with multiple file sets. The backtrace field is maintained for backwards compatibility only, and users are advised to port to the new field.

  • The cmake-file-api(7) "codemodel" version 2 "installers" object's optional fileSetType field gained a new SOURCES value to incorporate the new SOURCES file set type in codemodel replies.

Instrumentation

Generators

  • The Ninja Generators now support generating a build target named test_prep/<test-name> for each test added by add_test(), which builds all dependencies for that test. Build dependencies are registered for an executable target invoked by the test, targets referenced in generator expressions in the test command, and explicit dependencies added using the new BUILD_DEPENDS option. This behavior is enabled by the new CMAKE_TEST_BUILD_DEPENDS variable. A test_prep/all target is also generated to depend on every test_prep/<test-name> target. Tests with names that are not valid target names are excluded from this behavior. If multiple tests in different directories share the same name, their dependencies are merged into one test_prep/<test-name> target.

Languages

  • CUDA language level 23 (corresponding to C++ 23) is now supported with NVCC 13.3 and above.

Compilers

Command-Line

Commands

  • The block() command can now create a DIAGNOSTICS scope.

  • The cmake_diagnostic() command was added to manipulate CMake's diagnostic state.

  • The cmake_parse_arguments() command gained a new PARSE_ARGN signature that starts parsing after the last named argument of the calling function and works exactly like PARSE_ARGV with <N> being the number of parameters in the function definition.

  • The discover_tests() command was added to support registering tests discovered at test time by ctest(1). It runs a user-provided discovery command, parses its output, and generates test names, arguments, and properties from regular-expression captures.

  • The execute_process() command gained ENVIRONMENT and ENVIRONMENT_MODIFICATION options to run child processes with a modified environment.

  • The file(ARCHIVE_CREATE) and file(ARCHIVE_EXTRACT) commands gained an ENCODING option to specify the encoding of the archive pathnames. The default is now UTF-8. See policy CMP0213.

  • The file(READ_SYMLINK) command gained a RESULT option to capture errors without failing.

  • The include() command now has a NO_DIAGNOSTIC_SCOPE option.

  • The list(FILTER) command gained a new PREDICATE mode that invokes a user-defined function() to decide which elements are included or excluded, complementing the existing REGEX mode.

  • The list(SORT) command gained a new COMPARATOR keyword that invokes a user-defined function() to compare elements, complementing the built-in COMPARE methods.

  • The list(TRANSFORM) command gained a new APPLY action that invokes a user-defined function() for each element of the list, enabling arbitrary per-element transformations.

  • The list(TRANSFORM) command gained a new PREDICATE selector that invokes a user-defined function() to decide which elements are transformed.

  • The string(JSON ... PARTIAL_EQUAL) command was added to compare two JSON values using partial equality.

File Sets

  • A SOURCES file set type was added to specify a target's source files via file sets.

  • The CXX_SCAN_FOR_MODULES file set property was added to control whether a file set's sources are scanned for C++ modules.

  • The INDEPENDENT_FILES file set property was added to specify that a file set's sources do not depend on any generated files.

  • The JOB_POOL_COMPILE file set property was added to assign a file set's sources to a specific Ninja job pool.

  • The SCOPE, TYPE, BASE_DIRS, SOURCES, and INTERFACE_SOURCES file set properties were added to provide the declared details of a file set.

  • The SKIP_LINTING file set property was added to exclude a file set's sources from target-wide code checks.

  • The SKIP_PRECOMPILE_HEADERS file set property was added to avoid using precompiled headers for a file set's sources.

  • The SKIP_UNITY_BUILD_INCLUSION file set property was added to exclude a file set's sources from inclusion in unity builds.

Variables

Environment Variables

Properties

Modules

Generator Expressions

  • The TARGET_OBJECTS generator expression now has an optional SOURCE_FILES:... argument, which can take one or more source files as arguments, and will filter its output to only include objects built from those source files.

Swift

CTest

CPack

Deprecated and Removed Features

Other Changes

  • A file may belong to at most one non-HEADERS file set in a target. See policy CMP0211.

  • macro() invocations now preserve backslashes in arguments. See policy CMP0219.

  • variable_watch() callback command arguments preserve backslashes. See policy CMP0219.

  • ctest(1) now exits with non-zero if invoked with no arguments and no test input file exists.

  • Test drivers generated by the create_test_sourcelist() command now support the -N option to list all tests, one per line. This is useful in combination with the new discover_tests() command.

  • Names of executables given to the DEPENDS argument of add_custom_command() no longer have .exe suffixes stripped to establish target-level dependencies. See policy CMP0212.

  • Targets which provide C++ modules may now be consumed by targets with different compile features and options than the provider.