title: How to link 2 files in Cmake?
body: <p>I have researched this on Internet but I either don't understand the answers or the previous questions don't address my problem.</p>
  
  <p>I have 3 files A,B,C, where C is the executable and A,B just some library code I write myself. B depends on A. C depends on B and A. How do I properly link them in Cmake? I tried this:</p>
  
  <pre><code>add_library(A A.c)
  add_library(B B.c)
  add_executable(C C.c)
  target_link_libraries(B A)
  target_link_libraries(C B A)
  </code></pre>
  
  <p>Despite that I still get the "undefined reference to xxx" error. I really don't know what I did wrong.</p>