title: CMake: Build and install locally stored submodule
body: <p>There are numerous similar questions on Stack Overflow, but none come near to answering my question.</p>
  
  <p>I have a C++ library built using CMake:</p>
  
  <pre><code>mylib
  | - CMakeLists.txt
  | - src/
  |   | - m.h
  |   | - m.cpp
  | - include/
  |   | - mylib/
  |   |   | - a.h
  |   |   | - something/
  |   |   |   | - some.h
  | - cmake/
  |   - mylibConfig.cmake.in
  |   - mylibConfigVersion.cmake.in
  </code></pre>
  
  <p>I then create another library or executable which includes the aforementioned library:</p>
  
  <pre><code>myapp
  | - CMakeLists.txt
  | - src/
  |   | - main.cpp
  | - include/
  |   | - myapp/
  |   |   | - b.h
  | - libs
  |   | - mylib
  </code></pre>
  
  <p>And would like to use <code>mylib</code> within <code>myapp</code> like so. Please take notice how <code>mylib</code> headers are included in a directory like format:</p>
  
  <pre><code>#include &lt;mylib/a.h&gt;
  #include &lt;mylib/something/some.h&gt;
  </code></pre>
  
  <p><code>mylib</code> should be built when building <code>myapp</code> so that the following works <em>without any other build steps</em>:</p>
  
  <pre class="lang-sh prettyprint-override"><code>$ cd myapp/build
  $ cmake ..
  $ make
  </code></pre>
  
  <p>Here is a list of some of the Stack Overflow posts I have reviewed. I have attempted each, and they simply do not work:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/15175318/cmake-how-to-build-external-projects-and-include-their-targets">CMake: How to build external projects and include their targets</a></li>
  <li><a href="https://stackoverflow.com/questions/17446981/cmake-externalproject-add-and-findpackage?noredirect=1&amp;lq=1">CMake ExternalProject_Add() and FindPackage()</a></li>
  </ul>