[CMake] external projects and transitive dependencies

Ben Pope benpope81 at gmail.com
Thu Mar 20 03:35:20 EDT 2014


On Wednesday, March 19, 2014 10:11 AM, Brian Lewis wrote:
> If X brings in Y as an external project, and Y brings in Z as an
> external project, is there some way for Y to communicate information
> about Z back to X, e.g., some include directory?
>
> My situation is, X doesn't know anything about Z, but needs to be able
> to find one of Z's headers. I wish I could add Y as an external project
> and then include_directories(${Y_INCLUDE_DIRS}).

I haven't yet had a chance to play with this, but isn't it something like:

ExternalProject_Add(Z
    ...
)

set_property(TARGET Z
    INTERFACE_INCLUDE_DIRECTORIES
      "${relativeLocation}/include/Z"
)

ExternalProject_Add(Y
    ...
    DEPENDS Z
    ...
)

set_property(TARGET Y
    INTERFACE_INCLUDE_DIRECTORIES
      "${relativeLocation}/include/Y"
)

target(X
    ...
)

add_dependencies(X Y)

I have bookmarked this link for when I get round to doing this:
http://www.kdab.com/modern-cmake-with-qt-and-boost/

Ben




More information about the CMake mailing list