Cmake: read variables from another (processed) directory
<p>I am trying to interrogate the inclusion path of a series of addsubdirectories():</p>

<pre><code>-projectA
    -projectB
        -projectC
</code></pre>

<p>In this setup, <code>projectA</code> is adding <code>ProjectB</code> as a subdirectory which in turn adds <code>ProjectC</code> as a subdirectory. I want to let <code>projectC</code> know about the hierarchy.
I can achieve this by recursive calls</p>

<pre><code>get_directory_property(parent DIRECTORY ${cur_dir} PARENT_DIRECTORY)
</code></pre>

<p>which will return nothing when it reaches <code>projectA</code>. That almost does it. It would be nice however, if I could read the <code>${PROJECT_NAME}</code> from these directories and return <code>A-B-C</code> instead of <code>projectA-projectB-projectC</code>. </p>

<p>So my question is: Is there any way of reading the variables from a directory that is already parsed?</p>

<p>Note that in this case, although <code>projectC</code> would inherit variables from its parent, but the standard cache variables are replaced in the child projects, which is why I can't use them. </p>