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 2versionfield has been updated to 2.9.The
cmake-file-api(7)"codemodel" version 2 "target" and "directory" objects gained a newcodemodelVersionfield.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, andabstractfields.The "target" object's
typefield can now also hold the valueUNKNOWN_LIBRARY.The "codemodel" object's
configurationsentries gained a newabstractTargetsarray.Entries in the
directoriesandprojectsarrays of the "codemodel" object'sconfigurationsentries gained a newabstractTargetIndexesarray.
The
cmake-file-api(7)"codemodel" version 2 "target" object gained newlinkLibraries,interfaceLinkLibraries,compileDependencies,interfaceCompileDependencies,objectDependencies, andorderDependenciesfields.
Generators¶
The
Visual Studio 18 2026generator was added. This is experimental and based on "Visual Studio 2026 Insiders" because this version of VS has not been released.The
FASTBuildgenerator was added.
Platforms¶
CMake now supports Cross Compiling for Emscripten with simple toolchain files.
Command-Line¶
The
cmake(1)command-line tool now supportscmake -E copy_if_newerandcmake -E copy_directory_if_newersubcommands 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 tocopy_if_differentwhich compares file contents.
Commands¶
The
cmake_language(TRACE)command was added to enable or disable tracing during script execution.The
set(CACHE{<variable>})andunset(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_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_INTERMEDIATE_DIR_STRATEGYvariable and correspondingCMAKE_INTERMEDIATE_DIR_STRATEGYenvironment 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_STRATEGYvariable and correspondingCMAKE_AUTOGEN_INTERMEDIATE_DIR_STRATEGYenvironment variable were added to change the strategy used to name intermediate directories used forQt Autogenfiles.The
CMAKE_SKIP_LINTINGvariable and correspondingSKIP_LINTINGtarget property were added to tell the Command-Line Build Tool Generators to skip linting all sources in a target.
Properties¶
The
INSTALL_OBJECT_NAMEsource file property was added to control names of installed object files for specific compiled sources.The
INSTALL_OBJECT_NAME_STRATEGYtarget property was added to control the naming strategy for installed object files.The
INSTALL_OBJECT_ONLY_USE_DESTINATIONtarget property was added to more precisely control the installation path for object files.The
JOB_POOL_COMPILEsource file property was added to assign individual source compilations toJOB_POOLS.The
OBJECT_NAMEsource file property was added to control object names of compiled source files.The
UNITY_BUILD_FILENAME_PREFIXtarget property was added to control names of source files generated byUNITY_BUILD.
Modules¶
Nearly all find modules now provide a
<PackageName>_VERSIONresult variable matching the casing of its module name. Existing variants such as<PackageName>_VERSION_STRINGand uppercased<PACKAGENAME>_VERSIONare deprecated. See documentation of each find module for details.The
CheckTypeSizemodule'scheck_type_size()command gained a newRESULT_VARIABLEkeyword to customize the result variable name instead of the defaultHAVE_<size-var>.The
ExternalProjectmodule'sExternalProject_Add()andExternalProject_Add_Step()commands now provide options to set environment variables on the configure, build, install, and test steps.The
FindPython3,FindPython2, andFindPythonmodules no longer makeNumPydepend onDevelopment.Module. See policyCMP0201.The
GoogleTestmodule'sgtest_discover_tests()command now sets theDEF_SOURCE_LINEtest property for each discovered test if gtest supports the--gtest_output=jsonoption. This test property is used by some IDEs to locate the source for each test.The
UseSWIGmodule'sswig_add_library()command gained aDEBUG_POSTFIXoption to control theDEBUG_POSTFIXtarget property.
Generator Expressions¶
The
<LANG>_COMPILER_LINKER_IDand<LANG>_COMPILER_LINKER_FRONTEND_VARIANTfamilies of generator expressions were added to access the value of the associatedCMAKE_<LANG>_COMPILER_LINKER_IDandCMAKE_<LANG>_COMPILER_LINKER_FRONTEND_VARIANTvariables.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, andTARGET_PDB_FILE_BASE_NAMEgenerator expressions gained aPOSTFIXoption to control the inclusion of the<CONFIG>_POSTFIXtarget property as part of the base names of the corresponding files.The
TARGET_INTERMEDIATE_DIRgenerator expression was added to refer to a target's intermediate files directory in the build tree.
CPack¶
The
CPACK_PACKAGE_CHECKSUMvariable now supports multiple values.The
CPack NSIS Generatorgained aCPACK_NSIS_CRC_CHECKvariable for setting theCRCCheckattribute.The
CPack WIX Generatorgained aCPACK_WIX_CAB_PER_COMPONENTvariable to enable one.cabper component.
Deprecated and Removed Features¶
All find modules now provide a
<PackageName>_FOUNDresult 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
FindwxWidgetsmodule's result variablewxWidgets_USE_FILEis now deprecated in favor of including theUsewxWidgetsmodule directly.The
Visual Studio 14 2015generator 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 policyCMP0199.Selection of configuration and location of imported targets is now more consistent. See policy
CMP0200.The
CMAKE_PARENT_LIST_FILEvariable is no longer defined when processing aCMakeLists.txtfile. See policyCMP0198.For builds targeting the MSVC ABI, all generators now add the
_MBCSpreprocessor definition when compiling sources unless_UNICODEor_SBCSis found. See policyCMP0204.For builds targeting the MSVC ABI, all generators now add the
_WINDLLpreprocessor definition when compiling sources in shared libraries. See policyCMP0203.