Use generator expression to set build type specific flags
<p>I'd like to set some specific compile flags based on my current build configuration in cmake. I thought generator expressions would allow me to do this, but they don't appear to be working the way I expected.</p>

<p>I'm using the following command to set compile options to my main target. Both the expressions appear to always evaluate true as --debug and -Oh are passed to compiler no matter what CMAKE_BUILD_TYPE is set to.</p>

<pre><code>target_compile_options(${PROJECT_NAME}
   PUBLIC
   ${COMMON_COMPILER_FLAGS}
   $&lt;$&lt;CONFIG:Debug&gt;:--debug&gt;
   $&lt;$&lt;CONFIG:Release&gt;:-Oh&gt;
   )
</code></pre>

<p>I'm using cmake 3.4.1 on Windows and I'm cross-compiling with the IAR toolchain. To be more specific, I'm executing cmake from the bash shell in Cygwin, but its still the Windows executable. I'm using the Unix Makefile generator.</p>