1、通过命令行的方式
cmake -DCMAKE_BUILD_TYPE=Debug .. cmake -DCMAKE_BUILD_TYPE=Release ..
2、set(CMAKE_BUILD_TYPE Debug CACHE STRING “set build type to debug”)
set(CMAKE_BUILD_TYPE Release CACHE STRING “set build type to release”)
或者
set(CMAKE_BUILD_TYPE "Debug") set(CMAKE_BUILD_TYPE "Release")
文章来源: cmake 设置 debug release模式