title: CMake: correctly linking system library using gcc
body: <p>I have a static libary mylib that depends on the math library.</p>
  
  <p>If I first link mylib with math and then to my executable it works:</p>
  
  <pre><code>add_executable(myapp main.c)
  target_link_libraries(mylib m)
  target_link_libraries(myapp mylib)
  </code></pre>
  
  <p>But if I do the linking directly with the executable it fails when using gcc (with clang it works!)</p>
  
  <pre><code>add_executable(myapp main.c)
  target_link_libraries(myapp m mylib)
  </code></pre>
  
  <p>Why does this make any difference?<br>
  I thought that it is anyway not possible to link libraries together?</p>