[CMake] Transitively including dependency source directories

David Cole david.cole at kitware.com
Sat Oct 15 06:25:39 EDT 2011


On Fri, Oct 14, 2011 at 5:39 PM, Robert Dailey <rcdailey at gmail.com> 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.
>
> ---------
> Robert Dailey
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>

At present, in the CMakeLists file, there is no way for you to analyze
the dependencies unless you track this information yourself in CMake
variables. That is typically the approach used in larger projects that
have more complex dependencies. See, for example, ITK in its new
modular form. Or Trilinos.


HTH,
David


More information about the CMake mailing list