title: CMAKE API - producing an AST from the root CMakeFile
body: <p>I'm toying around with the idea of creating some tools for code analysis. My projects of interest all use cmake and clang++ now. </p>
  
  <p>To start with I need to get my hands on the CMake AST for a certain project. In essence I want to do the following (psuedocode):</p>
  
  <pre><code>CMakeAst &amp; project_ast = CMakeAstBuild("/path/to/the/root/directory/of/a/project");
  </code></pre>
  
  <p>From the AST I will extract the targets, the (default) compiler switches configured (, the (default) #DEFINE's, the include paths etc. All this information will be required for libClang to build an accurate AST for the targets defined in my project-under-analysis. </p>
  
  <p>So libclang is a clean documented interface to clang. I now need the information for CMake Could someone guide me to getting my own  CMake AST producing main program. Any information is welcome.</p>
  
  <p>A c-main and the relevant compile switches in the form of a MakeFile would make my day :D </p>
  
  <p><strong>Edit: My Progress (cmake 2.8.5)</strong> </p>
  
  <p><code>cmakemain.cxx</code> contains the main method and sets up the context for the main engine which seems to be a class <code>cmake</code> which is contained in <code>cmake.h</code>. <code>cmake.h</code> has good documentation. </p>
  
  <p>The build tools seem to build monolithic executable tools, no intermediary library is created. bit messy :/.</p>