[CMake] ExternalProject dependency question

Alexander Neundorf a.neundorf-work at gmx.net
Thu Oct 27 15:21:55 EDT 2011


On Wednesday 26 October 2011, Dan Kegel wrote:
> The manual says
> 
> "If you need to make your own CMake target depend on an external
> project use the CMake ADD_DEPENDENCIES command. The target name will
> be the first argument and the external project <name> will be the
> second argument."
> 
> But it seems kind of lame; it leaves external projects as second-class
> citizens that need two statements to reference instead of one.
> Isn't there a way to say "any project that uses
> ${CMAKE_BINARY_DIR}/prefix/lib/libblort.a dependes on Blort"?

CMake doesn't know what files the external project generates, so I don't see 
how this could be done automatically.
Maybe this could be done via some new additional parameters for 
externalproject_add() or a macro which wraps those three calls into one.

> More context:
> 
> I'm happily using ExternalProject_Add to compile something:
> 
> include(ExternalProject)
> ExternalProject_Add(
>     Blort
>     SOURCE_DIR ${CMAKE_SOURCE_DIR}/blort
>     INSTALL_DIR ${CMAKE_BINARY_DIR}/prefix
>     CONFIGURE_COMMAND ${CMAKE_SOURCE_DIR}/blort/configure -C
> --prefix=${CMAKE_BINARY_DIR}/prefix "CFLAGS=-g -O2 -fPIC"
> )
> SET(Blort_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/blort)
> SET(Blort_LIBRARIES ${CMAKE_BINARY_DIR}/prefix/lib/libblort.a)
> 
> Works fine... except that doing a "make -j9" with ccache just now,
> a build failed because libblort.a wasn't made in time.
> Looks like the code above doesn't end up adding the right
> dependencies.
> 
> (Is this related to http://www.cmake.org/Bug/view.php?id=10395 ?)

I think so.
And I would suggest you try what I mentioned in the initial note of that bug 
report. It should work.

Alex


More information about the CMake mailing list