[CMake] Best Practise for Multiple Platforms of External Project

Craig Scott craig.scott at crascit.com
Tue Dec 13 14:51:51 EST 2016


You could try using file(MAKE_DIRECTORY ...) between the two
ExternalProject_Add() calls to actually ensure the directory exists, but
I'm not 100% sure whether this would not interfere with the download step
when it goes to do that at build time. I'm pretty sure it works, but you
should confirm it.

Another choice is to do the download at configure time rather than build
time. This would mean the source would already be there by the time you
reached the second ExternalProject_Add() call in your example. There are
pros and cons to this, with the main objection being that ideally the
configure step should be quick and making the download part of configure
can increase the time that stage takes. For a general implementation
supporting this functionality, have a look here:

https://github.com/Crascit/DownloadProject



On Wed, Dec 14, 2016 at 12:29 AM, Bo Zhou <bo.schwarzstein at gmail.com> wrote:

> Hi
>
> In my project I have to compile the same external projects by the
> different generators, is that possible to handle this cases
> by ExternalProject_Add ?
>
> I tried this way, firstly, just download the repository
>
> ExternalProject_Add(OPENEXR_DOWNLOAD
>     PREFIX ${OPENEXR_PREFIX}
>     GIT_REPOSITORY https://github.com/openexr/openexr.git
>     GIT_TAG v2.2.0
>     CONFIGURE_COMMAND ""
>     BUILD_COMMAND ""
>     INSTALL_COMMAND "")
>
>
> ExternalProject_Get_Property(OPENEXR_DOWNLOAD SOURCE_DIR)
> SET(OPENEXR_SOURCE_DIR ${SOURCE_DIR})
>
> Then I tried to create a specific new target to use specific generator
>
> ExternalProject_Add(OPENEXR_VC11
>   DEPENDS OPENEXR_DOWNLOAD
>   SOURCE_DIR ${OPENEXR_SOURCE_DIR}/IlmBase)
>
>
> Seems can't work, it requires an non-empty SOURCE_DIR, but before
> downloading, it's empty :(
>
> So is there any better way to do this ? Thanks very much !
>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>



-- 
Craig Scott
Melbourne, Australia
https://crascit.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20161214/504c4f66/attachment.html>


More information about the CMake mailing list