让cmake支持GDB调试的方法

在CmakeLists.txt中加入以下代码即可:

    # Version 2.4 might work, but it won't find static libraries with odd names  
    cmake_minimum_required(VERSION 2.6)  
    SET(CMAKE_BUILD_TYPE "Debug")  
    SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")  
    SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")  

你可能感兴趣的:(c++)