title: How to write "CMakeLists.txt" for a big project with multiple subdirectories?
body: <p>I am working on a simulation project: Taking an <strong>embedded C</strong> codebase from a target platform and trying to simulate it on a Host computer for debugging or single stepping into the code.</p>
  
  <p>OS: Ubuntu Linux 14.04, IDE: CodeLite, Makefile Generator: <strong>Cmake</strong>. I am confused about how to write <strong>CMakeLists.txt</strong> for the project. Following is the structure of codebase (it's all written in <strong>C</strong>): </p>
  
  <pre><code>|ARQSim\  
  |--&gt;ARQSim.h  
  |--&gt;ARQSim.c  
  |--&gt;BaseStationCode\  
  |   |-&gt;downlink.c  
  |   |-&gt;neoncopy.c  
  |   |-&gt;armCore\  
  |   |  |-&gt;common\  
  |   |  |  |-&gt;Bsconfig.h  
  |   |  |  |-&gt;config.h  
  |   |  |-&gt;MacSource\  
  |   |  |  |-&gt;lib\  
  |   |  |  |  |-&gt;arqCommon.h  
  |   |  |  |  |-&gt;OverTheAir.h  
  |   |  |  |-&gt;source\  
  |   |  |  |  |-&gt;beacon.c  
  |   |  |  |  |-&gt;proxyDhcp.c  
  |   |  |  |  |-&gt;ARQ\  
  |   |  |  |  |  |-&gt;arqCommon.c  
  |   |  |  |  |  |-&gt;arqInterface.c  
  |   |  |  |  |  |-&gt;fragmentation\  
  |   |  |  |  |  |  |-&gt;fragBookkeeping.c  
  |   |  |  |  |  |  |-&gt;fragProcessAck.c  
  |   |  |  |  |  |-&gt;reassembly\  
  |   |  |  |  |  |  |-&gt;reasmBookkeeping.c  
  |   |  |  |  |  |  |-&gt;reasmProcessAck.c
  </code></pre>
  
  <p>I am totally new to Cmake. I have read up a lot of resources on CMake and threads here on StackOverflow. But I get confused every time. Few questions I have:</p>
  
  <ol>
  <li>Do I need only one CMakeLists.txt at root directory or every directory needs a different CMakeLists.txt file?</li>
  <li>How to add the source files recursively in CMakeLists.txt?</li>
  <li>What are the basic commands I need to put in CMakeLists.txt for MakeFile generation?</li>
  </ol>
  
  <p>An example based on the structure of code mentioned above would be appreciated.</p>