什么是CMAKE_BUILD_TYPE:调试,发布,RelWithDebInfo和MinSizeRel? [英] What are CMAKE_BUILD_TYPE: Debug, Release, RelWithDebInfo and MinSizeRel?
问题描述
从文档页面:
CMAKE_BUILD_TYPE
指定单配置生成器上的构建类型。
Specifies the build type on single-configuration generators.
此静态指定将在此构建树中构建哪种构建类型(配置)。可能的值为空, Debug
, Release
, RelWithDebInfo
和 MinSizeRel
。此变量仅对单配置生成器(例如 Makefile Generators
和 Ninja
有意义),即选择单个配置的生成器与多配置生成器相反,CMake运行时生成配置树,而多配置生成器提供了在生成的构建环境中选择构建配置的功能。每个配置的属性和变量很多(通常遵循干净的 SOME_VAR_< CONFIG>
顺序约定),例如 CMAKE_C_FLAGS_< CONFIG>
,以大写形式指定: CMAKE_C_FLAGS_ [DEBUG | RELEASE | RELWITHDEBINFO | MINSIZEREL]
。例如,在配置为生成类型 Debug
的生成树中,CMake将看到具有 CMAKE_C_FLAGS_DEBUG
设置已添加到 CMAKE_C_FLAGS
设置。另请参见 CMAKE_CONFIGURATION_TYPES
。
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
和<$ c $之间有什么区别c> RelWithDebInfo 和 MinSizeRel
?我猜 RelWithDebInfo
意味着创建可调试的二进制文件,而 MinSizeRel
意味着创建尽可能小的二进制文件。
I'm aware the differences between Debug
builds and Release
builds, but what are the differences between Release
, RelWithDebInfo
and MinSizeRel
? I'm guessing RelWithDebInfo
meant creating debuggable binaries, and MinSizeRel
meant creating smallest possible size binaries.
从 LLVM CMake页面:
CMAKE_BUILD_TYPE:STRING
如果您使用的是Visual Studio等IDE,应该使用IDE设置来设置构建类型。请注意,Release和RelWithDebInfo在大多数平台上使用不同的优化级别。
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.
如果要生成生产版本,应该选择发布
?
If I want to generate a production build, should I choose Release
?
推荐答案
RelWithDebInfo 与相同发布,使您可以使用符号文件进行调试。
RelWithDebInfo is the same as Release, allowing you to have symbol files for debugging.
例如,在Visual Studio中,您将拥有 .pdb
文件,如果没有这些文件,将很难调试,因为所有签名二进制文件中的 将是人类可读的,因此无法将它们映射到源代码。
For example in Visual Studio, you'll have .pdb
files and without them, it'll be hard to debug because all the signatures in the binary files are not going to be human readable and there's no way to map them to the source code.
MinSizeRel 与发布相同,其优化配置仅设置为在Visual Studio中最小化尺寸,最大化速度。
MinSizeRel is the same as Release, with its optimization configuration just set to Minimize size, Maximize speed in Visual Studio, for example.
如果要生成生产版本,应该选择发布吗?
If I want to generate a production build, should I choose Release?
是的,这应该适合您。调试/发布是最常用的选项。
Yes, that should do the right job for you. Debug/Release are the most commonly used options.
阅读此CMAKE常见问题解答实际上会对您有很大帮助。
Reading this CMAKE FAQ will actually help you a lot.
这篇关于什么是CMAKE_BUILD_TYPE:调试,发布,RelWithDebInfo和MinSizeRel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!