title: Usage of cmake flags in Relase and Debug mode
body: <p>I am trying to adapt a C++ library for my own usage and it contains the following lines in it's root CMakeLists.txt</p>
  <pre><code>set(BUILD_TYPE_RELEASE TRUE)
  
  set(CMAKE_CXX_FLAGS &quot;-O3 -no-pie -march=native -ggdb -Wall \
  -Wextra -Wcast-align -Wdisabled-optimization -Wformat=2 \
  -Winit-self -Wmissing-include-dirs -Woverloaded-virtual \
  -Wshadow -Wsign-promo -Werror&quot;)
  
  set(CMAKE_C_FLAGS &quot;-O3  -ggdb -std=gnu99 -I.&quot;)
  </code></pre>
  <p>Based on my understanding so far, it's build type is set to Release and certain optimization flags and Warnings are set to the C++ and C compilers. I have the following questions</p>
  <ol>
  <li>Debugging is usually done without any optimizations (<code>-O0</code>), so if I
  compile the code in debug mode by passing <code>-DCMAKE_BUILD_TYPE=Debug</code>,
  will the optimization flag of <code>CMAKE_CXX_FLAGS</code> automatically set to 0
  instead of 3?</li>
  <li>Is it relevant to have the gdb and warnings set to the C and CXX
  Flags, if the build type is set to Release mode?</li>
  <li>I am assuming these flags are relevant only when debugging with command line because while debugging with an IDE like VSCode, I would be asked to specify a debugger and it usually creates configurations automatically. Is this assumption correct?</li>
  </ol>
  <p>I may have to debug it in the future so I would like to have a clear understanding on how the release and debug modes play along with these flags. I am pretty new to CMake and debugging so, sorry if my questions are wrong in some sense. I would very much appreciate if someone link some resources for understanding the usage of these flags to this thread, I am having a hard time finding these in the cmake documentation.</p>
  <p>I am running the code on linux and my cmake version is 3.5.1</p>