[CMake] Transitively including dependency source directories

Michael Hertling mhertling at online.de
Wed Oct 19 10:46:23 EDT 2011


On 10/14/2011 11:39 PM, Robert Dailey wrote:
> If I have the following target dependency chain:
> 
> A >> B >> C >> D
> 
> Then target "D" must have the include directories (defined on a per project
> basis with a cache variable currently) for C, B, and A.
> 
> Right now I'm trying to implement the logic for this myself using macro
> recursion, but as of right now I don't know of any way to get the list of
> target dependencies from a target. For example, if I query target C's
> dependencies, I should get a list back with just "B" in it. Then when I
> query for B's dependencies, I should get a list with A in it.
> 
> I thought there might be a way to use get_target_property() for this, but
> doesn't seem so.
> 
> How would you all recommend I go about this? Am I completely off base?
> 
> Right now each target has a "${name}_INCLUDE_DIRS" internal cache variable,
> which is a list of that target's include directories, so that if other
> targets specify it as a dependency, they also know how to get to that
> target's header files.

You might attribute an accumulative/transitive meaning to variables
like ${name}_INCLUDE_DIRS: A_INCLUDE_DIRS contains its own include
directories only, B_INCLUDE_DIRS contains its own directories *and*
A_INCLUDE_DIRS etc. Since each target usually knows on which other
targets it immediately depends, this setup should be quite possible.

Regards,

Michael


More information about the CMake mailing list