[CMake] Detailed interpretation of build types

insert image description here

1. CMAKE_BUILD_TYPE official information

    CMake可以配置构建类型,例如:Debug、Release等,控制生成构建系统使用的配置变量 是 CMAKE_BUILD_TYPE 。该变量默认为空,CMake识别的值为:

Debug: Used to build a library or executable with debug symbols without optimization.
Release: An optimized library or executable for building, without debug symbols.
RelWithDebInfo: For building less optimized libraries or executables, including debug symbols.
MinSizeRel: Used to build libraries or executables in an optimized way that does not increase the size of the object code.


if(NOT CMAKE_BUILD_TYPE)
	set(CMAKE_BUILD_TYPE release)
endif()
 
message(STATUS "Build type:${CMAKE_BUILD_TYPE}")
 
message(STATUS "Debug configuration:${CMAKE_CXX_FLAGS_DEBUG}")
 
message(STATUS "release configuration:${CMAKE_CXX_FLAGS_RELEASE}")
 
message(STATUS "release configuration with debug info:${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
 
message(STATUS "minimal release configuration:${CMAKE_CXX_FLAGS_MINSIZEREL}")

Guess you like

Origin blog.csdn.net/Darlingqiang/article/details/131571974