CMake 4.2.0-rc2 is ready for testing

I am proud to announce the second CMake 4.2 release candidate.
https://cmake.org/download/

Documentation is available at:
https://cmake.org/cmake/help/v4.2

Release notes appear below and are also published at
https://cmake.org/cmake/help/v4.2/release/4.2.html

Release milestone is available at:
release milestone

Some of the most significant changes in CMake 4.2 are:

  • 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.

  • CMake now supports Cross Compiling for Emscripten with simple
    toolchain files.

  • The “set(CACHE{<variable>})” and “unset(CACHE{<variable>})” commands
    were added to explicitly set and unset cache entries.

  • The “INSTALL_OBJECT_NAME” source file property was added to control
    names of installed object files for specific compiled sources.

  • 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 “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 “Visual Studio 14 2015” generator is now deprecated and will be
    removed in a future version of CMake.

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

  • CMake now supports Cross Compiling for Emscripten with simple
    toolchain files.

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

  • The “cmake_language(TRACE)” command was added to enable or disable
    tracing during script execution.

  • The “set(CACHE{<variable>})” and “unset(CACHE{<variable>})” commands
    were added to explicitly set and unset cache entries.

  • The “string(REGEX QUOTE)” command was added to generate a regular
    expression exactly matching a string.

Variables

  • The “CMAKE_CXX_STDLIB_MODULES_JSON” variable was added to set the
    path to the “import std” metadata file for the standard library
    rather than using the compiler to discover its location.

  • The “CMAKE_INTERMEDIATE_DIR_STRATEGY” variable and corresponding
    “CMAKE_INTERMEDIATE_DIR_STRATEGY” environment variable were added to
    change the strategy used to name intermediate directories used for
    object files and other associated target metadata.

  • The “CMAKE_AUTOGEN_INTERMEDIATE_DIR_STRATEGY” variable and
    corresponding “CMAKE_AUTOGEN_INTERMEDIATE_DIR_STRATEGY” environment
    variable were added to change the strategy used to name intermediate
    directories used for “Qt Autogen” files.

  • The “CMAKE_SKIP_LINTING” variable and corresponding “SKIP_LINTING”
    target property were added to tell the Command-Line Build Tool
    Generators to skip linting all sources in a target.

Properties

  • The “INSTALL_OBJECT_NAME” source file property was added to control
    names of installed object files for specific compiled sources.

  • The “INSTALL_OBJECT_NAME_STRATEGY” target property was added to
    control the naming strategy for installed object files.

  • The “INSTALL_OBJECT_ONLY_USE_DESTINATION” target property was added
    to more precisely control the installation path for object files.

  • The “JOB_POOL_COMPILE” source file property was added to assign
    individual source compilations to “JOB_POOLS”.

  • The “OBJECT_NAME” source file property was added to control object
    names of compiled source files.

  • The “UNITY_BUILD_FILENAME_PREFIX” target property was added to
    control names of source files generated by “UNITY_BUILD”.

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

  • The “<LANG>_COMPILER_LINKER_ID” and
    “<LANG>COMPILER_LINKER_FRONTEND_VARIANT" families of generator
    expressions were added to access the value of the associated
    "CMAKE
    <LANG>COMPILER_LINKER_ID" and
    "CMAKE
    <LANG>_COMPILER_LINKER_FRONTEND_VARIANT” variables.

  • The “TARGET_FILE_BASE_NAME”, “TARGET_IMPORT_FILE_BASE_NAME”,
    “TARGET_LINKER_FILE_BASE_NAME”,
    “TARGET_LINKER_LIBRARY_FILE_BASE_NAME”,
    “TARGET_LINKER_IMPORT_FILE_BASE_NAME”, and
    “TARGET_PDB_FILE_BASE_NAME” generator expressions gained a “POSTFIX”
    option to control the inclusion of the “<CONFIG>_POSTFIX” target
    property as part of the base names of the corresponding files.

  • The “TARGET_INTERMEDIATE_DIR” generator expression was added to
    refer to a target’s intermediate files directory in the build tree.

CPack

  • The “CPACK_PACKAGE_CHECKSUM” variable now supports multiple values.

  • The “CPack NSIS Generator” gained a “CPACK_NSIS_CRC_CHECK” variable
    for setting the “CRCCheck” attribute.

  • The “CPack WIX Generator” gained a “CPACK_WIX_CAB_PER_COMPONENT”
    variable to enable one “.cab” per component.

Deprecated and Removed Features

  • All find modules now provide a “<PackageName>_FOUND” result variable
    matching the casing of its module name. Existing variants, such as
    the uppercased “<PACKAGENAME>_FOUND”, are deprecated 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, when appearing on an
    imported target, has been fixed to only match the configuration
    actually being consumed. 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”.


Changes made since CMake 4.2.0-rc1:

AJIOB (4):

  • Tests/RunCMake: Match xxx.cmake file name more precisely
  • Tests/RunCMake: Match CMakeLists.txt file name more precisely
  • Tests/RunCMake: fix version typo
  • Tests/RunCMake: Match dots more precisely, part 3

Andrej730 (3):

  • UseSWIG: Issue swig_link_libraries deprecation warning if CMP0078 is NEW
  • Tests: Fix RunCMake.UseSWIG SetPOSTFIX case on Windows
  • FindPython: Support getting DEBUG_POSTFIX without requiring Interpreter

Ben Boeckel (4):

  • PrecompileHeaders: downgrade REUSE_FROM without a PCH to a warning
  • Help/OPTIMIZE_DEPENDENCIES: fix parity of which files are considered
  • HELP/OPTIMIZE_DEPENDENCIES: fix reST markup
  • VS: do not create ProgramDataBaseFileName entries without a filepath

Brad King (18):

  • Compilers: Use -print-sysroot output only with successful exit code
  • Tests: Remove outdated CMake.PolicyCheck test
  • Help: Clarify 4.2 release note on $\<CONFIG\> policy CMP0199
  • ci: add unzip to cuda13.0 base image
  • macOS: Remove outdated condition for CMAKE_OSX_DEPLOYMENT_TARGET
  • macOS: Avoid relying on sw_vers when cross-compiling from another OS
  • VS: Fix SLNX generation so CSharp projects build in the IDE
  • Tests/FindBoost/TestPython: Improve python version list formatting
  • ci: Add job for CUDA with FASTBuild generator on Linux
  • ci: Add script to repackage macOS SDKs
  • ci: Add script to install macOS SDK version 15.5
  • ci: Revert packaging to macOS 15.5 SDK to restore cmake-gui rendering
  • Apple: Initialize deployment target after SDK
  • Xcode: Restore default CMAKE_OSX_DEPLOYMENT_TARGET to run on host
  • Tutorial: Restore source archive when published on cmake.org
  • VS: Restore support for Intel Fortran projects
  • macOS: Do not incorrectly search for per-arch SDKs
  • CMake 4.2.0-rc2

Craig Scott (1):

  • GoogleTest: Avoid POST_BUILD race condition for gtest_discover_tests()

Eduard Voronkin (6):

  • FASTbuild: allow setting custom IDE args
  • FASTBuild: Explicitly disallow CUDA language since it is not implemented
  • FASTBuild: optimize try_compile builds
  • FASTBuild: support CUDA language
  • FASTBuild: Disable caching and distribution in try_compile builds
  • FASTBuild: generate compile_commands

Karolina Surma (1):

  • FindPython: Add support for Python 3.15

Marc Chevrier (1):

  • Makefiles: Position target-wide link flags consistently with other generators

Martin Duffy (3):

  • install(PACKAGE_INFO): Fix error when usage requirements contain certain genex
  • instrumentation: Only quote arguments that contain a space
  • instrumentation: Add showOnly to ctest snippets

Matthew Woehlke (5):

  • Help: Add missing gate for project(SPDX_LICENSE)
  • find_package: Respect CPS license
  • Help: Improve documentation of project SPDX_LICENSE
  • cmPackageInfoArguments: Improve error message
  • CPS: Improve invalid namespace error

Ottmar Zittlau (1):

  • GoogleTest: Restore support for empty discovered test list

Tristan Daifuku (1):

  • Linker: Tolerate CMAKE_EXECUTE_PROCESS_COMMAND_ERROR_IS_FATAL set to ANY

Tyler Yankee (3):

  • Tests/Instrumentation: Remove unused files
  • Help/instrumentation: Fix link to CMake Content File
  • instrumentation: Fix snippet result field

Vito Gamberini (2):

  • Tutorial: Update IPO example in Step 6
  • Tutorial: Add Step 0 to prepare the working environment