title: CMake: Different compile definitions for static and shared library
body: <p>In a project using cmake, I build two versions of a library, one statically and one dynamically linked. For a single source file, I want to pass a different compile definition (i.e. <code>-Dfoo=bar</code>) when compiling for the shared library only.</p>
  
  <p>I know about <code>set_target_properties</code> where I can use the <code>COMPILE_DEFINITIONS</code> for a single source, but I don't know how to add that definition only for the shared library.</p>
  
  <p>How can this be done?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>To clarify how this question is different, I am already making two versions of the same library.</p>
  
  <pre><code>add_library(static_lib STATIC foo.cpp bar.cpp)
  add_library(dyn_lib SHARED foo.cpp bar.cpp)
  </code></pre>
  
  <p>What I would like to do is to add the target property that <code>foo.cpp</code> is compiled with <code>-Dbaz=True</code> <em>only</em> when compiling <code>foo.cpp</code> for <code>dyn_lib</code>.</p>