CMake 4.2 Release Notes

Changes made since CMake 4.1 include the following.

New Features

File-Based API

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

  • The cmake-file-api(7) "codemodel" version 2 "target" and "directory" objects gained a new codemodelVersion field.

  • The cmake-file-api(7) "codemodel" version 2 now includes imported targets and all interface library targets in its replies. Previously, imported targets were omitted, and only those interface targets that participated in the build system were included. The following changes support these new additions:

    • The "target" object gained imported, local, and abstract fields.

    • The "target" object's type field can now also hold the value UNKNOWN_LIBRARY.

    • The "codemodel" object's configurations entries gained a new abstractTargets array.

    • Entries in the directories and projects arrays of the "codemodel" object's configurations entries gained a new abstractTargetIndexes array.

  • The cmake-file-api(7) "codemodel" version 2 "target" object gained new linkLibraries, interfaceLinkLibraries, compileDependencies, interfaceCompileDependencies, objectDependencies, and orderDependencies fields.

Generators

  • The Visual Studio 18 2026 generator was added. This is experimental and based on "Visual Studio 2026 Insiders" because this version of VS has not been released.

  • The FASTBuild generator was added.

Platforms

Command-Line

  • The cmake(1) command-line tool now supports cmake -E copy_if_newer and cmake -E copy_directory_if_newer subcommands to copy files based on timestamp comparison instead of content comparison. These commands copy files only if the source is newer than the destination, providing better performance for build systems compared to copy_if_different which compares file contents.

Commands

Variables

Properties

Modules

  • Nearly all find modules now provide a <PackageName>_VERSION result variable matching the casing of its module name. Existing variants such as <PackageName>_VERSION_STRING and uppercased <PACKAGENAME>_VERSION are deprecated. See documentation of each find module for details.

  • The CheckTypeSize module's check_type_size() command gained a new RESULT_VARIABLE keyword to customize the result variable name instead of the default HAVE_<size-var>.

  • The ExternalProject module's ExternalProject_Add() and ExternalProject_Add_Step() commands now provide options to set environment variables on the configure, build, install, and test steps.

  • The FindPython3, FindPython2, and FindPython modules no longer make NumPy depend on Development.Module. See policy CMP0201.

  • The GoogleTest module's gtest_discover_tests() command now sets the DEF_SOURCE_LINE test property for each discovered test if gtest supports the --gtest_output=json option. This test property is used by some IDEs to locate the source for each test.

  • The UseSWIG module's swig_add_library() command gained a DEBUG_POSTFIX option to control the DEBUG_POSTFIX target property.

Generator Expressions

CPack

Deprecated and Removed Features

  • The uppercased <PACKAGENAME>_FOUND result variables of find modules are now deprecated in favor of <PackageName>_FOUND result variables, where appropriate. See documentation of each find module for details.

  • The FindwxWidgets module's result variable wxWidgets_USE_FILE is now deprecated in favor of including the UsewxWidgets module directly.

  • The Visual Studio 14 2015 generator is now deprecated and will be removed in a future version of CMake.

Other Changes

  • The $<CONFIG:cfgs> generator expression no longer matches multiple configurations. See policy CMP0199.

  • Selection of configuration and location of imported targets is now more consistent. See policy CMP0200.

  • The CMAKE_PARENT_LIST_FILE variable is no longer defined when processing a CMakeLists.txt file. See policy CMP0198.

  • For builds targeting the MSVC ABI, all generators now add the _MBCS preprocessor definition when compiling sources unless _UNICODE or _SBCS is found. See policy CMP0204.

  • For builds targeting the MSVC ABI, all generators now add the _WINDLL preprocessor definition when compiling sources in shared libraries. See policy CMP0203.