CMake 4.0 Release Notes¶
Changes made since CMake 3.31 include the following.
New Features¶
File-Based API¶
The
cmake-file-api(7)"codemodel" version 2versionfield has been updated to 2.8.The
cmake-file-api(7)"codemodel" version 2 "target" object gained a newdebuggerfield.
Command-Line¶
The
cmake --link-no-warning-as-erroroption was added to suppress the effects of theLINK_WARNING_AS_ERRORtarget property andCMAKE_LINK_WARNING_AS_ERRORvariable.The
cmake --project-fileoption was added to specify an alternate filename forCMakeLists.txtfiles. This is intended for temporary use by developers during an incremental transition and not for publication of a final product. CMake will always emit a warning when the project file is anything other thanCMakeLists.txt.
Commands¶
The
target_link_libraries()command now supports theLINKER:prefix.
Variables¶
The
AIXandCMAKE_HOST_AIXvariables are now set to true when the target or host system is AIX, respectively.Linker flag variables learned to support the
LINKER:prefix:See policy
CMP0181.The
CMAKE_EXECUTE_PROCESS_COMMAND_ERROR_IS_FATALvariable was added to specify theexecute_process()command's defaultCOMMAND_ERROR_IS_FATALbehavior.The
CMAKE_<LANG>_LINK_MODEandCMAKE_<LANG>_DEVICE_LINK_MODEvariables were added to provide information on how the link step is done.The
CMAKE_LINK_WARNING_AS_ERRORvariable and correspondingLINK_WARNING_AS_ERRORtarget property were added to link using a linker-specific flag to treat warnings as errors.The
CMAKE_MSVC_RUNTIME_CHECKSvariable andMSVC_RUNTIME_CHECKStarget property were introduced to select runtime checks for compilers targeting the MSVC ABI. See policyCMP0184.The
CMAKE_POLICY_VERSION_MINIMUMvariable was added to help packagers and end users try to configure existing projects that have not been updated to work with supported CMake versions. TheCMAKE_POLICY_VERSION_MINIMUMenvironment variable was added to initialize it.The
CMAKE_UNITY_BUILD_RELOCATABLEvariable and correspondingUNITY_BUILD_RELOCATABLEtarget property were added to make sources generated forCMAKE_UNITY_BUILDto#includethe original source files using relative paths where possible.The
CMAKE_XCODE_SCHEME_LLDB_INIT_FILEvariable and correspondingXCODE_SCHEME_LLDB_INIT_FILEtarget property were added to tell theXcodegenerator what to put in the scheme's "LLDB Init File" setting.The
CMAKE_XCODE_SCHEME_TEST_CONFIGURATIONvariable and correspondingXCODE_SCHEME_TEST_CONFIGURATIONtarget property were added to tell theXcodegenerator what to put in the scheme's "Build Configuration" setting for the test action.
Properties¶
The
DEBUGGER_WORKING_DIRECTORYtarget property and correspondingCMAKE_DEBUGGER_WORKING_DIRECTORYvariable were added to tell generators what debugger working directory should be set for targets.The
STATIC_LIBRARY_OPTIONStarget property now supports anARCHIVER:prefix to pass options to the archiver through the compiler driver in a portable way.The
Swift_MODULE_DIRECTORYtarget property now supportsgenerator expressions.The
VS_CUSTOM_COMMAND_DISABLE_PARALLEL_BUILDsource file property was added to tell Visual Studio Generators not to run a custom command in parallel.The
VS_SOLUTION_ITEMSdirectory property was added to tell Visual Studio Generators to attach files directly to the Solution (.sln).
Modules¶
The
ExternalDatamodule gained aExternalData_HTTPHEADERSvariable to specify HTTP headers.The
ExternalProjectmodule'sExternalProject_Add()command gained anINSTALL_JOB_SERVER_AWAREoption to enable integration of the GNU Make job server when using an explicitINSTALL_COMMANDwith Makefile Generators.The
FeatureSummarymoduleadd_feature_info()command now supports full Condition Syntax. See policyCMP0183.The
FindBISONmodulebison_target()command gained anOPTIONSoption to specify Bison command-line options.The
FindCURLmodule now provides aCURL_VERSIONresult variable to match upstream cURL's CMake package.The
FindFLEXmoduleflex_target()command gained anOPTIONSoption to specify Flex command-line options.The
FindPatchmodule now supports running in cmake -P script mode by skipping the creation of the imported target.The
FindProtobufmoduleprotobuf_generate()command gained aPROTOC_EXEoption to specify a customprotocexecutable.The
FindPython,FindPython2, andFindPython3modules gained the possibility to do multiple calls in the same directory by using, respectively, the variablesPython_ARTIFACTS_PREFIX,Python2_ARTIFACTS_PREFIX, andPython3_ARTIFACTS_PREFIX.The
FindRubymodule learned to find rbenv-provided installations.
Generator Expressions¶
The
$<PATH>generator expression gained theNATIVE_PATHoperation to convert a CMake path into a native one.
CTest¶
The
ctest --interactive-debug-modeoption on Windows now enables Windows Error Reporting by default in test processes, allowing them to creating debug popup windows and core dumps. This restores behavior previously removed by CMake 3.11 after updates tolibuvmade it possible.
CPack¶
The
CPack Archive Generatorlearned to generate.tarpackages without compression.The
CPack Archive Generatornow honors theCPACK_ARCHIVE_FILE_NAMEvariable for all packages. Previously, this variable worked only for component-based packages.
Deprecated and Removed Features¶
Compatibility with versions of CMake older than 3.5 has been removed. Calls to
cmake_minimum_required()orcmake_policy()that set the policy version to an older value now issue an error. Note that calls to those commands can still support older versions of CMake by using theirVERSIONarguments'<min>...<max>syntax. This requires only the<min>version of CMake, but when running a newer version, sets policies up to the<max>version.The
Visual Studio 14 2015andVisual Studio 15 2017generators no longer support specifying a platform as part of the generator name. See Visual Studio Platform Selection.The
CMAKE_<LANG>_USING_LINKER_MODEvariable is no longer used to determine the type of the contents of theCMAKE_<LANG>_USING_LINKER_<TYPE>variable. TheCMAKE_<LANG>_LINK_MODEvariable, set by CMake, is used instead.The
FindGDALmodule is now deprecated in favor of upstream GDAL's official CMake package configuration file. Port projects to the latter by callingfind_package(GDAL CONFIG). For further details, see GDAL's documentation on CMake integration.The
FindRubymodule no longer provides variables with the upper-caseRUBY_prefix. See policyCMP0185.CTest's undocumented declarative scripting mode has been removed. This mode used to be triggered by a
ctest -Sscript which did not call any CTest Commands unlessCTEST_RUN_CURRENT_SCRIPTwas explicitly set toOFF.The
ctest_run_script()command may no longer be called without any arguments.
Other Changes¶
On macOS with Ninja Generators and Makefile Generators, when a compiler is found in
/usr/bin, it is now used as-is and is no longer mapped to the corresponding compiler inside Xcode. The mapping was introduced by CMake 3.2 to allow build trees to continue to work with their original compiler even whenxcode-selectswitches to a different Xcode installation. However, the compilers inside Xcode cannot be used without explicit-isysrootflags and are therefore not suitable for passing to arbitrary third-party build systems. Furthermore, the mapping behavior can override user-specified compiler paths. Therefore, this behavior has been reverted.Builds targeting macOS no longer choose any SDK or pass an
-isysrootflag to the compiler by default. Instead, compilers are expected to choose a default macOS SDK on their own. In order to use a compiler that does not do this, users must now specifyCMAKE_OSX_SYSROOTwhen configuring their build, e.g.,-DCMAKE_OSX_SYSROOT=macosx.Note that Xcode's compilers, when not invoked with
-isysroot, search for headers in/usr/local/includebefore system SDK paths, matching the convention on many platforms. Users on macOS-x86_64 hosts with Homebrew installed in/usr/localshould pass-DCMAKE_OSX_SYSROOT=macosx, orexport SDKROOT=macosx, when not building with Homebrew tools.On AIX,
SHAREDlibrary targets now produce a shared library archive by default. See policyCMP0182.The
cmake --presetcommand no longer outputs a summary of the preset's CMake cache and environment variables by default. That summary is now only shown when the message log level is set toVERBOSE,DEBUG, orTRACEvia thecmake --log-leveloption or theCMAKE_MESSAGE_LOG_LEVELcache variable.Precompiled SunOS
sparc64andx86_64binaries are now provided on cmake.org.
Updates¶
Changes made since CMake 4.0.0 include the following.
4.0.1¶
This version made no changes to documented features or interfaces. Some implementation updates were made to support ecosystem changes and/or fix regressions.