title: CMake: What do CMake build types (DCMAKE_BUILD_TYPE) do?
body: <p>I am using CMake (within CLion IDE but that should not matter for this discussion). Up until now I have been using things like <code>set(CMAKE_C_FLAGS &quot;${CMAKE_C_FLAGS} -O2&quot;)</code> or <code>set(CMAKE_CXX_FLAGS &quot;${CMAKE_CXX_FLAGS} -O2&quot;)</code> to set compiler options for GCC. I assume CMake passes these on directly to the compiler. However, CMake is supposed to be platform independent and (at least in principle) able to build the same code using different compilers. Does this mean one should do it differently?</p>
  <p>I have been thinking about using build configurations. For example, I assume calling CMake with a build type flag:</p>
  <p><code>cmake .. -DCMAKE_BUILD_TYPE=&quot;Release&quot;</code></p>
  <p>enables some optimization. I was unable, however, to find any documentation on what exactly this flag does (maybe because it depends on things like the compiler being used). I have two questions:</p>
  <ol>
  <li>What does -DCMAKE_BUILD_TYPE=&quot;Release&quot; (and other release types) do (as exactly as one can tell not knowing the system where the build happens)?</li>
  <li>What is the best way to view the compiler and <strong>all</strong> options actually being used at build time (both using CMake in command line and within an IDE like CLion) ?</li>
  </ol>
  <p>Reading the makefile generated by CMake to find the flags does not seem like an option to me. I tried setting <code>VERBOSE=yes</code> for Make but somehow it didn't give me compiler flags, just some &quot;entering end exiting directories&quot;.</p>