I suppose that using cmake with CMAKE_BUILD_TYPE adds appropriate compiler flag to CMAKE_CXX_FLAGS.
However, once I typed the following command and then see the content of CMAKE_CXX_FLAGS, nothing expected was added.
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=DEBUG
Below is the snippet of my CMakeLists.txt.
... #version and project name
set(CMAKE_CXX_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS_DEBUG "-g3")
message(${CMAKE_CXX_FLAGS})
From the message, I expected it to show -Wall -g3.
But what was shown was only -Wall, seeming that CMAKE_CXX_FLAGS_DEBUG was not added to CMAKE_CXX_FLAGS as opposed to the explanation given in https://cmake.org/cmake/help/v3.0/variable/CMAKE_BUILD_TYPE.html.
It says that
For example, in a build tree configured to build type Debug, CMake will see to having CMAKE_C_FLAGS_DEBUG settings get added to the CMAKE_C_FLAGS settings. See also CMAKE_CONFIGURATION_TYPES.
In my case, which one was indeed used, CMAKE_CXX_FLAGS or CMAKE_CXX_FLAGS_DEBUG?