什么是 CMAKE_BUILD_TYPE:调试、发布、RelWithDebInfo 和 MinSizeRel? [英] What are CMAKE_BUILD_TYPE: Debug, Release, RelWithDebInfo and MinSizeRel?

查看:50
本文介绍了什么是 CMAKE_BUILD_TYPE:调试、发布、RelWithDebInfo 和 MinSizeRel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自文档页面:

<块引用>

CMAKE_BUILD_TYPE

在单一配置生成器上指定构建类型.

这静态指定将在此构建树中构建的构建类型(配置).可能的值为空、DebugReleaseRelWithDebInfoMinSizeRel.此变量仅对单配置生成器(例如 Makefile GeneratorsNinja)有意义,即那些在 CMake 运行以生成构建树时选择单个配置的生成器,而不是多配置生成器,可在生成的构建环境中选择构建配置.有许多 per-config 属性和变量(通常遵循干净的 SOME_VAR_ 顺序约定),例如 CMAKE_C_FLAGS_,指定为大写:CMAKE_C_FLAGS_[调试|发布|RELWITHDEBINFO|MINSIZEREL].例如,在配置为构建类型 Debug 的构建树中,CMake 将看到将 CMAKE_C_FLAGS_DEBUG 设置添加到 CMAKE_C_FLAGS 设置中.另请参阅CMAKE_CONFIGURATION_TYPES.

我知道 Debug 构建和 Release 构建之间的区别,但是 ReleaseRelWithDebInfo<之间的区别是什么/code> 和 MinSizeRel?我猜 RelWithDebInfo 意味着创建可调试的二进制文件,而 MinSizeRel 意味着创建尽可能小的二进制文件.

来自 LLVM CMake 页面:

<块引用>

CMAKE_BUILD_TYPE:STRING

如果您使用的是 Visual Studio 等 IDE,则应使用 IDE 设置来设置构建类型.请注意,Release 和 RelWithDebInfo 在大多数平台上使用不同的优化级别.

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

解决方案

RelWithDebInfoRelease 相同,允许您拥有 符号文件 用于调试.

例如在 Visual Studio 中,您将拥有 .pdb 文件,如果没有它们,将很难调试,因为二进制文件中的所有签名都不会 人类可读,并且无法将它们映射到源代码.

MinSizeRelRelease 相同,只是将其优化配置设置为 Minimize Size 而不是 Maximize Speed> 例如,如 Visual Studio 中的此链接所示.><块引用>

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

是的,这应该适合您.调试/发布是最常用的选项.

阅读这个 CMAKE 常见问题实际上会对你有很大帮助.

From the 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.

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.

From the 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.

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

解决方案

RelWithDebInfo is the same as Release, allowing you to have symbol files for debugging.

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 is the same as Release, with its optimization configuration just set to Minimize Size instead of Maximize Speed as illustrated in this link 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.

Reading this CMAKE FAQ will actually help you a lot.

这篇关于什么是 CMAKE_BUILD_TYPE:调试、发布、RelWithDebInfo 和 MinSizeRel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆