CMake 4.1 Release Notes¶
Changes made since CMake 4.0 include the following.
New Features¶
File-Based API¶
The
cmake-file-api(7)v1 now writes partial replies when buildsystem generation fails with an error. See the v1 Reply Error Index.
Generators¶
Makefile Generators and Ninja Generators gained support for adding a linker launcher with
Fortran,CUDA, andHIP. See theCMAKE_<LANG>_LINKER_LAUNCHERvariable and<LANG>_LINKER_LAUNCHERtarget property for details.
Command-Line¶
The cmake --build command-line tool, when used with the
Xcodegenerator, now detects when a third-party tool has wrapped the generated.xcodeprojin a.xcworkspace, and drives the build through the workspace instead.
Configure Log¶
The
cmake-configure-log(7)now reports events fromfind_package()(inCONFIGmode),find_path(),find_file(),find_library(), andfind_program()commands when first invoked, when their results transition between "not found" and "found", or when enabled explicitly by the--debug-findcommand-line option. See Event Kind find and Event Kind find_package. Logging may also be controlled by theCMAKE_FIND_DEBUG_MODEandCMAKE_FIND_DEBUG_MODE_NO_IMPLICIT_CONFIGURE_LOGvariables.
Compilers¶
Diab compilers from Wind River Systems, versions 5.9.x+, are now supported with
compiler idDiabfor languagesASM,C, andCXX.
Renesas Compilers are now supported with
compiler idRenesasfor languagesASMandC.
Commands¶
The
add_dependencies()command may be called with no dependencies.The
cmake_pkg_config()command now supports theIMPORTandPOPULATEsubcommands for interfacing CMake targets with pkg-config based dependencies.The
project()command now has experimental support for theCOMPAT_VERSIONkeyword, gated byCMAKE_EXPERIMENTAL_EXPORT_PACKAGE_INFO.
Variables¶
The
CMAKE_FIND_REQUIREDvariable was added to tellfind_package(),find_path(),find_file(),find_library(), andfind_program()to beREQUIREDby default. The commands also gained anOPTIONALkeyword to ignore the variable for a specific call.The
CMAKE_<LANG>_COMPILER_ARCHITECTURE_IDvariable is now populated for most compilers, and documented for public use.The
CMAKE_<LANG>_ICSTATvariable and corresponding<LANG>_ICSTATtarget property were added to tell the Makefile Generators and the Ninja Generators to run the IARicstattool along with the compiler forCandCXXlanguages.
Environment Variables¶
The
CMAKE_<LANG>_IMPLICIT_LINK_LIBRARIES_EXCLUDEenvironment variable was added to optionally exclude specific libraries from the detected set ofCMAKE_<LANG>_IMPLICIT_LINK_LIBRARIES.
Properties¶
The
AUTOMOC_INCLUDE_DIRECTORIEStarget property and associatedCMAKE_AUTOMOC_INCLUDE_DIRECTORIESvariable were added to override the automatic discovery of moc includes from a target's transitive include directories.The
MACOSX_PACKAGE_LOCATIONsource file property now works when set on a source directory, and copies its entire tree into the bundle.The
PDB_NAMEandCOMPILE_PDB_NAMEtarget properties now supportgenerator expressions.
Modules¶
The
FindASPELLmodule now provides a version variable, imported targets, and components to optionally select the Aspell library and executable separately.The
FindBLASandFindLAPACKmodules now support the NVIDIA Performance Libraries (NVPL).The
FindProtobufmodule'sprotobuf_generate(DEPENDENCIES)command argument now accepts multiple values.The
FindProtobufmodule'sprotobuf_generate_cpp()andprotobuf_generate_python()commands, together with theirProtobuf_IMPORT_DIRSandPROTOBUF_GENERATE_CPP_APPEND_PATHhint variables, are now deprecated in favor of theprotobuf_generate()command.
Regular Expressions¶
The
string(REGEX MATCHALL),string(REGEX REPLACE), andlist(TRANSFORM REPLACE)commands now match the regular expression^anchor at most once in repeated searches, at the start of the input. See policyCMP0186.The
string(REGEX REPLACE)command now allows references to unmatched groups. They are replaced with empty strings.The
string(REGEX MATCH),string(REGEX MATCHALL), andstring(REGEX REPLACE)commands now allow zero-length matches.
CTest¶
ctest(1)gained a--schedule-random-seedoption to specify a numeric random seed to makectest --schedule-randomdeterministic for reproduction.
CPack¶
The
CPack NuGet Generatorgained optionCPACK_NUGET_SYMBOL_PACKAGEto generate NuGet symbol packages containing PDB files.The
CPack RPM GeneratorgainedCPACK_RPM_PACKAGE_ENHANCES,CPACK_RPM_PACKAGE_RECOMMENDS, andCPACK_RPM_PACKAGE_SUPPLEMENTSvariables to specify the corresponding RPM spec fields.
Deprecated and Removed Features¶
The
FindGTestmodule's result variablesGTEST_INCLUDE_DIRS,GTEST_LIBRARIES,GTEST_MAIN_LIBRARIES, andGTEST_BOTH_LIBRARIESare now deprecated in favor of usingGTest::gtestandGTest::gtest_mainimported targets.The
FindGCCXMLmodule has been deprecated via policyCMP0188. Port projects to CastXML instead.The
FindCABLEmodule has been deprecated via policyCMP0191.The
CMakeDetermineVSServicePackmodule has been deprecated via policyCMP0196. Port projects to theCMAKE_<LANG>_COMPILER_VERSIONvariable instead.
Other Changes¶
The
ExternalProjectmodule no longer checks theURLarchive file extension. Any archive type thatcmake -E tarcan extract is now allowed.Modules
FindPython3,FindPython2andFindPythonnow enforce consistency of artifacts in cross-compiling mode. This prevents mixing host and target artifacts. See policyCMP0190.The
GNUInstallDirsmodule now prefers to defaultSYSCONFDIR,LOCALSTATEDIR, andRUNSTATEDIRto absolute paths when installing to special prefixes. See policyCMP0192.The
GNUInstallDirsmodule now cachesCMAKE_INSTALL_*variables with their leadingusr/for install prefix/. See policyCMP0193.The
install(TARGETS)command no longer ignores file sets which haven't been defined at the point it is called. The ordering oftarget_sources(FILE_SET)andinstall(TARGETS)is no longer semantically relevant.Enabling
ASMno longer accidentally succeeds usingMSVC'sclC compiler as an assembler. See policyCMP0194.The MSVC link
-machine:flag is no longer added to theCMAKE_*_LINKER_FLAGSvariables. See policyCMP0197.The
TARGET_PROPERTYgenerator expression now evaluates theLINK_LIBRARIESandINTERFACE_LINK_LIBRARIEStarget properties transitively. See policyCMP0189.
Updates¶
Changes made since CMake 4.1.0 include the following.
4.1.1¶
This version made no changes to documented features or interfaces. Some implementation updates were made to support ecosystem changes and/or fix regressions.
4.1.2¶
The
file(GENERATE)command, when evaluating generator expressions, now uses the value of policyCMP0189as of each call site. Previously, it used the value as of the end of the directory'sCMakeLists.txt, as all other generator expression evaluations do.