[CMake] How to add dependencies to ExternalProject_Add()

David Cole david.cole at kitware.com
Mon Mar 28 11:02:52 EDT 2011


On Mon, Mar 28, 2011 at 10:48 AM, Rolf Eike Beer <eike at sf-mail.de> wrote:

> > I came up with this simple diff which makes everything work smoothly for
> > me:
>
> This also works for me and should properly detect if the dependency is
> itself an external target or not:
>
> diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
> index 3de6b7e..90b23ce 100644
> --- a/Modules/ExternalProject.cmake
> +++ b/Modules/ExternalProject.cmake
> @@ -1261,8 +1261,14 @@ function(_ep_add_configure_command name)
>    set(file_deps)
>   get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS)
>   foreach(dep IN LISTS deps)
> +    # Find out if this dependency is itself an external target or not.
> +    # If it doesn't have _EP_STAMP_DIR we assume it's a normal target.
>      get_property(dep_stamp_dir TARGET ${dep} PROPERTY _EP_STAMP_DIR)
> -    list(APPEND file_deps ${dep_stamp_dir}${cfgdir}/${dep}-done)
> +    if(dep_stamp_dir)
> +      list(APPEND file_deps ${dep_stamp_dir}${cfgdir}/${dep}-done)
> +    else(dep_stamp_dir)
> +      list(APPEND file_deps ${dep})
> +    endif(dep_stamp_dir)
>    endforeach()
>
>   get_property(cmd_set TARGET ${name} PROPERTY _EP_CONFIGURE_COMMAND SET)
>
> Eike
> _______________________________________________
> 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
>


I am not sure I like this patch, or not. I'm on the fence.

I would recommend just using:

  ExternalProject_Add(xyz ...)
  add_dependencies(xyz mylib)

to add non-ExternalProject dependencies. Just to make it clear that the
dependencies are target-level dependencies and not file dependencies.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110328/5db131c3/attachment.htm>


More information about the CMake mailing list