From d4e6ec0ff00aa9c7c4613e0390467dbc847349d1 Mon Sep 17 00:00:00 2001 From: Oak Zeng Date: Mon, 6 Nov 2017 16:47:47 -0500 Subject: [PATCH] Added "-g" to CFLAGS for debug build Previously even for debug build, -O2 is used. So there wasn't debug information in the debug build. Change-Id: I6334474e007480eb2db191bdfec5a71677c26a52 Signed-off-by: Oak Zeng --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 39ef33e653..0592150e6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,11 +53,16 @@ set ( BUILD_VERSION_STRING "${BUILD_VERSION_MAJOR}.${BUILD_VERSION_MINOR}.${BUIL set ( CMAKE_VERBOSE_MAKEFILE on ) ## Compiler flags -set ( CMAKE_C_FLAGS "-fPIC -W -Wall -Wextra -Wno-unused-parameter -Wformat-security -Wswitch-default -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wlogical-op -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wunreachable-code -std=gnu99 -fvisibility=hidden -O2" ) +set ( CMAKE_C_FLAGS "-fPIC -W -Wall -Wextra -Wno-unused-parameter -Wformat-security -Wswitch-default -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wlogical-op -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wunreachable-code -std=gnu99 -fvisibility=hidden" ) if ( "${CMAKE_C_COMPILER_VERSION}" STRGREATER "4.8.0") set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror" ) endif () +if ( "${CMAKE_BUILD_TYPE}" STREQUAL Release ) + set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2" ) +else () + set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g" ) +endif () set ( HSAKMT_LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/src/libhsakmt.ver" )