title: Multiple static library inclusion in CMake TARGET_LINK_LIBRARIES
body: <p>I have a <code>CMake</code> multiple definition linking problem with an executable that depends on a shared library that contains a static library.</p>
  
  <p>I create a shared library <code>foo</code> that depends on a static library <code>bar</code>.</p>
  
  <pre><code>add_library(foo SHARED foo.cpp)
  target_link_libraries(foo bar)
  </code></pre>
  
  <p>By definition, the content of <code>bar</code> is in library <code>foo</code>.</p>
  
  <p>Then I create an executable <code>exe</code> that depends on <code>foo</code>.</p>
  
  <pre><code>add_executable(exe exe.cpp)
  target_link_libraries(exe foo)
  </code></pre>
  
  <p>At linking time, I have a <code>multiple definition</code> warning/error that tells me that functions in library <code>bar</code> are present twice. When looking at the linking command, I see that <code>exe</code> is linked against <code>bar</code> and <code>foo</code>, which is not consistent.</p>
  
  <p>Do I miss something in the declaration of dependencies? Do I miss a magic <code>CMake</code> keyword?</p>