[CMake] ExternalProject dependency question

David Cole david.cole at kitware.com
Thu Oct 27 17:49:21 EDT 2011


On Thu, Oct 27, 2011 at 4:44 PM, Dan Kegel <dank at kegel.com> wrote:
> On Thu, Oct 27, 2011 at 1:35 PM, Alexander Neundorf
> <a.neundorf-work at gmx.net> wrote:
>>> But I'm confused.
>>> http://www.cmake.org/Bug/view.php?id=10395 is marked as fixed in 2.8.4.
>>> Does that mean I can do something like
>>> set_property(TARGET log4cplus PROPERTY DEPENDS EP_log4cplus)
>>> and have it work?
>>
>> add_dependencies(), yes.
>
> I'm still confused.  Can you give an example?  I thought you had to
> use add_dependencies
> every time you refer to the external library, and would rather just have
> one statement right after externalproject_add that would take care
> of the dependency no matter how many times you referred to the external library.
>
>>> If so, shouldn't that be mentioned in
>>> http://www.kitware.com/products/html/BuildingExternalProjectsWithCMake2.8.html ?
>>
>> That page is from end of 2009, while cmake 2.8.4 is much newer.
>
> Where's the newer doc?
> - Dan
> --
>
> 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
>

This whole thread is the reason I recommend using ExternalProject
either exclusively, for building all targets, or not at all.

Your ExternalProject_Add builds a library called
"${CMAKE_BINARY_DIR}/prefix/lib/libblort.a" -- but CMake has no way of
knowing this, or of connecting dependencies up based on the
information you give to ExternalProject_Add.

So, if you have other non-ExternalProject entities that depend on the
output of an ExternalProject_Add... you need to use add_dependencies
to force the ExternalProject target to be completely done before any
compile/link steps are run on internal targets that come later that
depend on that output.


HTH,
David


More information about the CMake mailing list