[CMake] External projects and imported targets

Marcus D. Hanwell marcus.hanwell at kitware.com
Sun May 16 14:11:38 EDT 2010


On Sun, May 16, 2010 at 12:48 PM, Timothy M. Shead <tshead at k-3d.com> wrote:

> I'd like to do the following:
>
>  # Build external project A
>  ExternalProject_Add(A ...)
>
>  # Import target B, which is exported by A in AConfig.cmake
>  ExternalProject_Get_Property(A, BINARY_DIR)
>  set(A_DIR ${BINARY_DIR})
>  find_package(A)
>
>  # Link with B
>  add_library(C ...)
>  target_link_libraries(C B)
>
> Of course, this doesn't work because the external project hasn't been
> built yet at configure-time, so AConfig.cmake doesn't exist.  Which
> leads me to the following:
>
> Hi,

If I understand your question correctly, then adding DEPENDS A to your
ExternalProject_Add(B...) call will ensure that A has been built when B is
configured, thus satisfying your need to find A's exported targets. Using
the dependencies between external projects it is possible to control the
build order, so that A's config file will be present before B attempts a
configure step.

Hope that helps, I will take a look at this case in a moment and do some
test builds.

Thanks,

Marcus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100516/eac42427/attachment.htm>


More information about the CMake mailing list