CMake 3.30 发行说明¶
自 CMake 3.29 以来的变更包括:
新功能¶
预设¶
cmake-presets(7)
文件现在支持 schema 版本9
。include
字段现在会展开除$env{}
和预设特定宏(即源自预设定义内部字段的宏)之外的所有宏。
基于文件的 API¶
The
cmake-file-api(7)
"cmakeFiles" 版本 1 对象中的version
字段已更新为 1.1。它增加了一个globsDependent
字段,用于报告使用CONFIGURE_DEPENDS
的file(GLOB)
调用。
生成器¶
Visual Studio 生成器 现在会向
.vcxproj
文件添加UseDebugLibraries
指示符,以表明哪些配置是调试配置。参见策略CMP0162
。
语言¶
The
Compile Features
功能现在实现了对cxx_std_26
和cuda_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
CMAKE_<LANG>_STANDARD_LATEST
变量被添加,用于描述 CMake 为选定的编译器支持的最新<LANG>
语言标准。The
CMAKE_TLS_VERIFY
环境变量被添加,作为现有CMAKE_TLS_VERIFY
变量的回退。它指定了是否默认验证https://
URL 的服务器证书。The
CMAKE_TLS_VERSION
变量和CMAKE_TLS_VERSION
环境变量被添加,用于为https://
URL 的连接指定一个默认的最低 TLS 版本,供file(DOWNLOAD)
和file(UPLOAD)
命令使用。The
CMAKE_VS_USE_DEBUG_LIBRARIES
变量和对应的VS_USE_DEBUG_LIBRARIES
目标属性被添加,用于显式控制.vcxproj
文件中的UseDebugLibraries
指示符。
属性¶
The
GENERATED
源文件属性现在在所有目录中都可见。参见策略CMP0163
。策略CMP0118
的文档已被修订,以描述其实际效果。The
PROPAGATE_TOP_LEVEL_INCLUDES_TO_TRY_COMPILE
全局属性可用于将CMAKE_PROJECT_TOP_LEVEL_INCLUDES
传播到使用 整个项目签名 的try_compile()
调用中。这主要用于使依赖提供者能够在此类try_compile()
调用中启用。A
VS_FILTER_PROPS
target property was added to tell Visual Studio 生成器 to use a custom MSBuild filter.props
file.
模块¶
The
ExternalProject
模块的ExternalProject_Add()
命令增加了TLS_VERSION <min>
选项,并支持CMAKE_TLS_VERSION
变量和CMAKE_TLS_VERSION
环境变量,以指定与https://
URL 的连接的最低 TLS 版本。The
FindBacktrace
模块现在提供了一个导入的目标。The
FindBLAS
和FindLAPACK
模块增加了对libblastrampoline
的支持。The
FindCUDAToolkit
模块现在提供了一个针对libnvfatbin
和libnvfatbin_static
的目标(如果找到)。The
FindCUDAToolkit
模块现在即使在CUDA
语言未启用时,也会搜索CMAKE_CUDA_COMPILER
变量和CUDACXX
环境变量。The
FindOpenMP
模块增加了OpenMP_RUNTIME_MSVC
选项,用于控制与 MSVC 一起使用的 OpenMP 运行时。The
FindPython
和FindPython3
模块增加了对自由线程 Python 版本(free threaded Python version)的支持。The
FindPython
、FindPython2
和FindPython3
模块在 Windows 上现在对 Python 调试版本提供了更好的支持。新变量
Python_EXECUTABLE_DEBUG
Python_INTERPRETER
Python_DEBUG_POSTFIX
新目标
Python::InterpreterDebug
Python::InterpreterMultiConfig
The
python_add_library()
command now manages theDEBUG_POSTFIX
target property based on the value of thePython_DEBUG_POSTFIX
variable.
生成器表达式¶
The
<LANG>_COMPILER_FRONTEND_VARIANT
family of generator expressions were added to access the value of the associatedCMAKE_<LANG>_COMPILER_FRONTEND_VARIANT
variables.Link features, as used with the
LINK_LIBRARY
generator expression, gained the ability to have attributes that describe their behavior by specifying theCMAKE_LINK_LIBRARY_<FEATURE>_ATTRIBUTES
orCMAKE_<LANG>_LINK_LIBRARY_<FEATURE>_ATTRIBUTES
variables.The
QUOTE
generator expression was added to evaluate to"
.The
TARGET_PROPERTY
generator expression learned to evaluate 自定义传递属性 defined by newTRANSITIVE_COMPILE_PROPERTIES
和TRANSITIVE_LINK_PROPERTIES
target properties.The
TARGET_PROPERTY
generator expression now evaluates target propertiesINTERFACE_LINK_OPTIONS
,INTERFACE_LINK_DIRECTORIES
, andINTERFACE_LINK_DEPENDS
correctly by following private dependencies of static libraries. See policyCMP0166
.
CTest¶
The
ctest_submit()
command andctest -T Submit
step gainedTLSVersion
andTLSVerify
options to control negotiation withhttps://
URLs. See theCTEST_TLS_VERSION
andCTEST_TLS_VERIFY
variables.
CPack¶
The
CPack Inno Setup Generator
is now available on non-Windows hosts.The
CPack NuGet Generator
gained theCPACK_NUGET_PACKAGE_README
,CPACK_NUGET_PACKAGE_REPOSITORY_URL
,CPACK_NUGET_PACKAGE_REPOSITORY_TYPE
,CPACK_NUGET_PACKAGE_REPOSITORY_BRANCH
, andCPACK_NUGET_PACKAGE_REPOSITORY_COMMIT
variables.The
CPack NuGet Generator
can now generate dependency groups for framework-specific dependencies. TheCPACK_NUGET_PACKAGE_TFMS
variable was added to specify a list of target framework monikers (TFMs) for which groups should be generated.The
CPack WIX Generator
gained support for WiX Toolset v4. See theCPACK_WIX_VERSION
variable.
弃用和移除的功能¶
The
FindBoost
模块已根据策略CMP0167
被移除。请将项目移植到上游 Boost 的BoostConfig.cmake
配置文件,find_package(Boost)
现在会搜索该文件。Calling
FetchContent_Populate()
with just the name of a dependency is now deprecated. Projects should callFetchContent_MakeAvailable()
instead. See policyCMP0169
. CallingFetchContent_Populate()
with full population details rather than just a dependency name remains fully supported.The
Visual Studio 9 2008
generator has been removed.
其他更改¶
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-widePATH
by default. When replacing an existing installation of 3.30 or later, thePATH
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. PolicyCMP0168
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 ofFetchContent_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 policyCMP0170
.
更新¶
自 CMake 3.30.0 以来的变更包括:
3.30.1, 3.30.2¶
这些版本未对已记录的功能或接口进行任何更改。为了支持生态系统更改和/或修复回归,进行了一些实现更新。
3.30.3¶
The
project(<PROJECT-NAME>)
command now sets<PROJECT-NAME>_SOURCE_DIR
,<PROJECT-NAME>_BINARY_DIR
, and<PROJECT-NAME>_IS_TOP_LEVEL
as normal variables in addition to setting them as cache entries. This is needed to preserve support for someFetchContent
use cases under policyCMP0169
's NEW behavior.The
FindPython
和FindPython3
模块现在分别定义了Python_DEFINITIONS
和Python3_DEFINITIONS
变量在 Windows 上,以支持使用自由线程 Python 版本进行开发。为这些模块提供的各种目标也定义了INTERFACE_COMPILE_DEFINITIONS
目标属性。
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 whenproject()
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 callproject()
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 toproject()
with the same project name and you use these variables.
3.30.5¶
The
project(<PROJECT-NAME>)
command now sets<PROJECT-NAME>_SOURCE_DIR
,<PROJECT-NAME>_BINARY_DIR
, and<PROJECT-NAME>_IS_TOP_LEVEL
as non-cache variables only if they are already set as non-cache variables whenproject()
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 callproject()
with the same project name, and it addresses the bug in the implementation introduced in 3.30.4.
3.30.6, 3.30.7, 3.30.8, 3.30.9¶
这些版本未对已记录的功能或接口进行任何更改。为了支持生态系统更改和/或修复回归,进行了一些实现更新。