gpt4 book ai didi

cmake - 什么是 CMAKE_BUILD_TYPE : Debug, Release、RelWithDebInfo 和 MinSizeRel?

转载 作者:行者123 更新时间:2023-12-04 00:03:42 25 4
gpt4 key购买 nike

来自 docs page :

CMAKE_BUILD_TYPE

Specifies the build type on single-configuration generators.

This statically specifies what build type (configuration) will be built in this build tree. Possible values are empty, Debug, Release, RelWithDebInfo and MinSizeRel. This variable is only meaningful to single-configuration generators (such as Makefile Generators and Ninja) i.e. those which choose a single configuration when CMake runs to generate a build tree as opposed to multi-configuration generators which offer selection of the build configuration within the generated build environment. There are many per-config properties and variables (usually following clean SOME_VAR_<CONFIG> order conventions), such as CMAKE_C_FLAGS_<CONFIG>, specified as uppercase: CMAKE_C_FLAGS_[DEBUG|RELEASE|RELWITHDEBINFO|MINSIZEREL]. For example, in a build tree configured to build type Debug, CMake will see to having CMAKE_C_FLAGS_DEBUG settings get added to the CMAKE_C_FLAGS settings. See also CMAKE_CONFIGURATION_TYPES.


我知道 Debug 之间的区别构建和 ​​ Release构建,但 Release 之间有什么区别? , RelWithDebInfoMinSizeRel ?我猜 RelWithDebInfo意味着创建可调试的二进制文件,以及 MinSizeRel意味着创建尽可能小的二进制文件。
来自 LLVM CMake page :

CMAKE_BUILD_TYPE:STRING

If you are using an IDE such as Visual Studio, you should use the IDE settings to set the build type. Be aware that Release and RelWithDebInfo use different optimization levels on most platforms.


如果我想生成一个生产版本,我应该选择 Release ?

最佳答案

RelWithDebInfo 相同发布 ,让您拥有symbol files用于调试。
例如,在 Visual Studio 中,您将拥有 .pdb如果没有它们,将很难调试,因为二进制文件中的所有签名都不是人类可读的,并且无法将它们映射到源代码。
MinSizeRel 相同发布 ,其优化配置刚刚设置为 Minimize Size而不是 Maximize Speedthis link 中所示例如,在 Visual Studio 中。

If I want to generate a production build, should I choose Release?


是的,这应该适合您。调试/发布是最常用的选项。
阅读 this CMAKE FAQ实际上会帮助你很多。

关于cmake - 什么是 CMAKE_BUILD_TYPE : Debug, Release、RelWithDebInfo 和 MinSizeRel?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48754619/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com