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_PROPStarget property was added to tell Visual Studio 生成器 to use a custom MSBuild filter.propsfile.
模块¶
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_DEBUGPython_INTERPRETERPython_DEBUG_POSTFIX
新目标
Python::InterpreterDebugPython::InterpreterMultiConfig
The
python_add_library()command now manages theDEBUG_POSTFIXtarget property based on the value of thePython_DEBUG_POSTFIXvariable.
生成器表达式¶
The
<LANG>_COMPILER_FRONTEND_VARIANTfamily of generator expressions were added to access the value of the associatedCMAKE_<LANG>_COMPILER_FRONTEND_VARIANTvariables.Link features, as used with the
LINK_LIBRARYgenerator expression, gained the ability to have attributes that describe their behavior by specifying theCMAKE_LINK_LIBRARY_<FEATURE>_ATTRIBUTESorCMAKE_<LANG>_LINK_LIBRARY_<FEATURE>_ATTRIBUTESvariables.The
QUOTEgenerator expression was added to evaluate to".The
TARGET_PROPERTYgenerator expression learned to evaluate 自定义传递属性 defined by newTRANSITIVE_COMPILE_PROPERTIES和TRANSITIVE_LINK_PROPERTIEStarget properties.The
TARGET_PROPERTYgenerator expression now evaluates target propertiesINTERFACE_LINK_OPTIONS,INTERFACE_LINK_DIRECTORIES, andINTERFACE_LINK_DEPENDScorrectly by following private dependencies of static libraries. See policyCMP0166.
CTest¶
The
ctest_submit()command andctest -T Submitstep gainedTLSVersionandTLSVerifyoptions to control negotiation withhttps://URLs. See theCTEST_TLS_VERSIONandCTEST_TLS_VERIFYvariables.
CPack¶
The
CPack Inno Setup Generatoris now available on non-Windows hosts.The
CPack NuGet Generatorgained theCPACK_NUGET_PACKAGE_README,CPACK_NUGET_PACKAGE_REPOSITORY_URL,CPACK_NUGET_PACKAGE_REPOSITORY_TYPE,CPACK_NUGET_PACKAGE_REPOSITORY_BRANCH, andCPACK_NUGET_PACKAGE_REPOSITORY_COMMITvariables.The
CPack NuGet Generatorcan now generate dependency groups for framework-specific dependencies. TheCPACK_NUGET_PACKAGE_TFMSvariable was added to specify a list of target framework monikers (TFMs) for which groups should be generated.The
CPack WIX Generatorgained support for WiX Toolset v4. See theCPACK_WIX_VERSIONvariable.
弃用和移除的功能¶
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 2008generator has been removed.
其他更改¶
ctest(1)now rejects unknown command-line arguments with an error. Previously they were silently ignored.The precompiled Windows
.msiinstallers provided on cmake.org, when performing a fresh installation, now modify the system-widePATHby default. When replacing an existing installation of 3.30 or later, thePATHmodification preference is preserved by default.The official
.zipsource 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.
FetchContentnow 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 --freshalso forces the download, update, and patch steps of directly populated dependencies to be re-executed. PolicyCMP0168provides backward compatibility for those projects that still rely on using a sub-build for content population.When
FETCHCONTENT_FULLY_DISCONNECTEDis 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_LEVELas normal variables in addition to setting them as cache entries. This is needed to preserve support for someFetchContentuse 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_LEVELas 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_LEVELas 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¶
这些版本未对已记录的功能或接口进行任何更改。为了支持生态系统更改和/或修复回归,进行了一些实现更新。