I am reading a C++ project and want to print out the #ifdef _DEBUG message when running the program at a Linux terminal. For example:
#ifdef _DEBUG
cout << s1 << endl;
#endif
Currently, it doesn't print out the debug info above, but only prints out logger info as below:
logger_(MY_MODULE_LOG_ERROR, "config is null ");
The project is made through cmake. It has a top level CMakeLists.txt file, in addition to each CZMakeLists.txt under src/ and its subdirectories. The content of the top-level CMakelists.txt is below:
cmake_minimum_required (VERSION 3.12)
project (TAGS_NEW )
set(CMAKE_VERBOSE_MAKEFILE true)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -w")
# gdb debug : -g
add_compile_options(
-Wall
-Wextra
-Wstrict-aliasing
-Wno-unused-parameter
-Wno-missing-field-initializers
-Wchar-subscripts
-Wpointer-arith
-Wformat
-Wformat-security
-Werror=format-security
-fstack-protector-all
-fPIE
-fpie
-fPIC
-fpic
-pipe
-fdata-sections
-ffunction-sections
)
option(DEBUG_OUTPUT "option for debug out" OFF)
if (DEBUG_OUTPUT)
add_definitions(-D_DEBUG)
endif()
# option(DEBUG_GDB "option for gdb debug" OFF)
# if (DEBUG_GDB)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -ggdb")
# endif()
# set(CMAKE_BUILD_TYPE "Debug")
option(CMAKE_BUILD_TYPE "option for gdb debug" DEBUG)
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
option(COMPILE_DLL "option for generate dynamic library" OFF)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${TAGS_NEW_SOURCE_DIR}/output)
add_definitions(-D_Python_CALL -D_ChaiScriptON)
include_directories(${TAGS_NEW_SOURCE_DIR}/third-party/include ${TAGS_MINING_NEW_SOURCE_DIR}/include )
# $(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")
find_package( PythonLibs 2.7 REQUIRED )
include_directories( ${PYTHON_INCLUDE_DIRS} )
link_directories(${TAGS_NEW_SOURCE_DIR}/third-party/lib)
add_subdirectory (src)
execute_process(COMMAND sh genGlobal.sh ${TAGS_NEW_SOURCE_DIR} WORKING_DIRECTORY ${TAGS_NEW_SOURCE_DIR})
I tried to change the OFF to ON in the line below, but it doesn't help:
option(DEBUG_OUTPUT "option for debug out" OFF)
I am new to CMake. How to print out all the debug info?