2019年1月19日 星期六

[cmake 學習筆記] 如何設定 GDB debug flag (-g)

方法一: 在 cmake 指令下增加參數


cmake -DCMAKE_BUILD_TYPE=Debug <路徑與其他參數>



cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo <路徑與其他參數>


方法二: 修改 CMakeLists.txt


set(CMAKE_BUILD_TYPE Debug)



set(CMAKE_BUILD_TYPE RelWithDebInfo)


--
build type 為 Debug 會產生具有 debug symbols 與未最佳化的 code
build type 為 RelWithDebInfo 會產生具有 debug symbols 與最佳化的 code