CMake 3.30 发行说明

自 CMake 3.29 以来的变更包括:

新功能

预设

  • cmake-presets(7) 文件现在支持 schema 版本 9include 字段现在会展开除 $env{} 和预设特定宏(即源自预设定义内部字段的宏)之外的所有宏。

基于文件的 API

  • The cmake-file-api(7) "cmakeFiles" 版本 1 对象中的 version 字段已更新为 1.1。它增加了一个 globsDependent 字段,用于报告使用 CONFIGURE_DEPENDSfile(GLOB) 调用。

生成器

  • Visual Studio 生成器 现在会向 .vcxproj 文件添加 UseDebugLibraries 指示符,以表明哪些配置是调试配置。参见策略 CMP0162

语言

  • The Compile Features 功能现在实现了对 cxx_std_26cuda_std_26 元特征的支持,以指示编译器模式必须至少为 C++26。这些元特征最早由 CMake 3.25 记录,但并未完全实现。

命令

  • The add_library() 命令在不支持共享库的平台上,现在会拒绝创建共享库,而不是自动将其转换为静态库。参见策略 CMP0164

  • The enable_language() 命令现在如果在第一次 project() 调用之前被调用,则会以错误告终。参见策略 CMP0165

  • The file(DOWNLOAD)file(UPLOAD) 命令增加了 TLS_VERSION <min> 选项,用于指定与 https:// URL 的连接的最低 TLS 版本。

变量

属性

模块

  • The ExternalProject 模块的 ExternalProject_Add() 命令增加了 TLS_VERSION <min> 选项,并支持 CMAKE_TLS_VERSION 变量和 CMAKE_TLS_VERSION 环境变量,以指定与 https:// URL 的连接的最低 TLS 版本。

  • The FindBacktrace 模块现在提供了一个导入的目标。

  • The FindBLASFindLAPACK 模块增加了对 libblastrampoline 的支持。

  • The FindCUDAToolkit 模块现在提供了一个针对 libnvfatbinlibnvfatbin_static 的目标(如果找到)。

  • The FindCUDAToolkit 模块现在即使在 CUDA 语言未启用时,也会搜索 CMAKE_CUDA_COMPILER 变量和 CUDACXX 环境变量。

  • The FindOpenMP 模块增加了 OpenMP_RUNTIME_MSVC 选项,用于控制与 MSVC 一起使用的 OpenMP 运行时。

  • The FindPythonFindPython3 模块增加了对自由线程 Python 版本(free threaded Python version)的支持。

  • The FindPythonFindPython2FindPython3 模块在 Windows 上现在对 Python 调试版本提供了更好的支持。

    • 新变量

      • Python_EXECUTABLE_DEBUG

      • Python_INTERPRETER

      • Python_DEBUG_POSTFIX

    • 新目标

      • Python::InterpreterDebug

      • Python::InterpreterMultiConfig

    The python_add_library() command now manages the DEBUG_POSTFIX target property based on the value of the Python_DEBUG_POSTFIX variable.

生成器表达式

CTest

CPack

弃用和移除的功能

其他更改

  • ctest(1) now rejects unknown command-line arguments with an error. Previously they were silently ignored.

  • The precompiled Windows .msi installers provided on cmake.org, when performing a fresh installation, now modify the system-wide PATH by default. When replacing an existing installation of 3.30 or later, the PATH modification preference is preserved by default.

  • The official .zip source archive provided on cmake.org now uses LF newlines, instead of CRLF newlines, for consistency with modern conventions.

  • The durations printed after "Configuring done" and "Generating done" messages now reflect time spent in generator-specific steps, and in a code model evaluation step at the beginning of generation that was not previously captured. Printed durations may appear longer than in previous versions of CMake, but are more accurate.

  • FetchContent now prefers to populate content directly rather than using a separate sub-build. This may significantly improve configure times on some systems (Windows especially, but also on macOS when using the Xcode generator). cmake --fresh also forces the download, update, and patch steps of directly populated dependencies to be re-executed. Policy CMP0168 provides backward compatibility for those projects that still rely on using a sub-build for content population.

  • When FETCHCONTENT_FULLY_DISCONNECTED is set to true, FetchContent_MakeAvailable() and the single-argument form of FetchContent_Populate() require that the dependency's source directory has already been populated. CMake 3.29 and earlier did not check this requirement, but it is now enforced, subject to policy CMP0170.

更新

自 CMake 3.30.0 以来的变更包括:

3.30.1, 3.30.2

  • 这些版本未对已记录的功能或接口进行任何更改。为了支持生态系统更改和/或修复回归,进行了一些实现更新。

3.30.3

3.30.4

  • The project(<PROJECT-NAME>) command now sets <PROJECT-NAME>_SOURCE_DIR, <PROJECT-NAME>_BINARY_DIR, and <PROJECT-NAME>_IS_TOP_LEVEL as normal variables only if they are already set as cache or non-cache variables when project() is invoked. Cache entries by the same names are always set as before. This refines 3.30.3's behavior change to restore behavior of nested directories that call project() with the same project name, but the implementation in this release is flawed (this release note has been retroactively updated). It can result in different behavior between the first and subsequent runs. Do not use CMake 3.30.4 if your project contains nested calls to project() with the same project name and you use these variables.

3.30.5

3.30.6, 3.30.7, 3.30.8, 3.30.9

  • 这些版本未对已记录的功能或接口进行任何更改。为了支持生态系统更改和/或修复回归,进行了一些实现更新。