title: Internal dependencies with cmake in a large project
body: <p>I have a project with multiple libraries which have dependencies between them.
  It looks similar to this:</p>
  <pre><code>project
  + libs
  | + lib1
  | + lib2
  | + lib3
  + apps
  | + app1
  | + app2
  </code></pre>
  <p>I have dependencies between different targets. For example, <code>lib2</code> depends on <code>lib1</code> and <code>lib3</code> depends on <code>lib2</code> (note transitive dependency here). Apps mostly depends on arbitrary number of libs.</p>
  <p>I would like to have a <code>CMakeLists.txt</code> in the project root and in each library and application folder.</p>
  <p>I assume that in the main <code>CMakeLists.txt</code> I will use <code>add_subdirectory()</code> to include other <code>CMakeLists.txt</code> files but I'm not sure what is the best practice to reflect dependencies between different targets (library on other libraries and application on libraries) since they reside on the same level. In other words I would like to know how <code>CMakeLists.txt</code> for <code>lib2</code> and <code>lib3</code> could look like.</p>
  <p><strong>Update:</strong></p>
  <p>I managed to find a potential solution: people suggest to use <code>add_dependencies(lib1 lib2)</code>. Should this be specified before all the <code>add_subdirectory()</code>?</p>