Disable optimization for debug builds
Always applying -O2 prevents a debugger from correctly tracking and
analyzing symbols. This patch gives -O0 to a compiler when being built
as a debug build.
@@ -16,7 +16,10 @@ IF (WITH_DTRACE)
MESSAGE(STATUS "Enabling USDT support")
ENDIF ()
-SET(CMAKE_C_FLAGS "-std=c99 -Wall -O2 -g ${CC_WARNING_FLAGS} ${CMAKE_C_FLAGS}")
+SET(CMAKE_C_FLAGS "-std=c99 -Wall -g ${CC_WARNING_FLAGS} ${CMAKE_C_FLAGS}")
+SET(CMAKE_C_FLAGS_DEBUG "-O0")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
INCLUDE_DIRECTORIES(
${OPENSSL_INCLUDE_DIR}
deps/klib
