Cmake Parameter

cmake 编译选项之修改CFLAGS和CXXFLAGS

全局编译

修改CmakeLists.txt,添加

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g")

区分编译

修改CmakeLists.txt,添加

set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
set(CMAKE_C_FLAGS_Release "${CMAKE_C_FLAGS_Release} -DNDBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
set(CMAKE_CXX_FLAGS_Release "${CMAKE_CXX_FLAGS_Release} -DNDBUG")

区分

Debug

mkdir debug
cd debug
cmake -DCMAKE_BUILD_TYPE=Debug ..
make

Release

mkdir release
cd release
cmake -DCMAKE_BUILD_TYPE=Release ..
make