来自 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
andMinSizeRel
. This variable is only meaningful to single-configuration generators (such asMakefile Generators
andNinja
) 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 cleanSOME_VAR_<CONFIG>
order conventions), such asCMAKE_C_FLAGS_<CONFIG>
, specified as uppercase:CMAKE_C_FLAGS_[DEBUG|RELEASE|RELWITHDEBINFO|MINSIZEREL]
. For example, in a build tree configured to build typeDebug
, CMake will see to havingCMAKE_C_FLAGS_DEBUG
settings get added to theCMAKE_C_FLAGS
settings. See alsoCMAKE_CONFIGURATION_TYPES
.
我知道
Debug
之间的区别构建和 Release
构建,但 Release
之间有什么区别? , RelWithDebInfo
和 MinSizeRel
?我猜 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 Speed
如 this 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/