[CMake] Don't download external projects again after calling "make clean"

David Cole DLRdave at aol.com
Fri Apr 17 07:21:08 EDT 2015


Eliminate your DOWNLOAD_COMMAND. CMake knows how to do it with just
the URL_MD5, DOWNLOAD_DIR and SOURCE_DIR information....

HTH,
David


On Fri, Apr 17, 2015 at 1:32 AM, Cedric Doucet <cedric.doucet at inria.fr> wrote:
>
> Hello David,
>
> thank you very much for your help.
>
> Unfortunately I may do something wrong because it does not work.
> After cleaning, the library is downloaded again.
>
> I guess my mistake comes from the fact I do not understand the role of URL_MD5.
> Below is a simple example where downloading and installing is very fast.
> You just have to replace the value of EXTERNAL_DIR by the path to your own "Downloads" repository.
> I tried to put URL in my DOWNLOAD_COMMAND but the call "wget <URL>" does not seem to be understood by the wget command.
>
> Thanks again!
>
> Cédric
>
> --------------------------------------------------------------------------
> cmake_minimum_required (VERSION 2.6)
>
> project (example CXX)
>
> set(CMAKE_VERBOSE_MAKEFILE ON)
>
> include(ProcessorCount)
> ProcessorCount(N)
> if(NOT N EQUAL 0)
>   set(CMAKE_BUILD_FLAGS -j${N})
> endif()
>
> include(ExternalProject)
> set(EXTERNAL_DIR /home/cdoucet/Downloads)
> ExternalProject_Add(eigen
>                     PREFIX ${EXTERNAL_DIR}/eigen
>                     DOWNLOAD_DIR ${EXTERNAL_DIR}/eigen/download
>                     SOURCE_DIR ${EXTERNAL_DIR}/eigen/src
>                     BINARY_DIR ${EXTERNAL_DIR}/eigen/build
>                     INSTALL_DIR ${EXTERNAL_DIR}/eigen/install
>                     URL http://bitbucket.org/eigen/eigen/get/3.2.4.tar.gz
>                     URL_MD5 ccb18a771f678b38a3d33c321a8e7daf
>                     DOWNLOAD_COMMAND wget http://bitbucket.org/eigen/eigen/get/3.2.4.tar.gz && tar xvzf 3.2.4.tar.gz -C <SOURCE_DIR> --strip-components=1
>                     CONFIGURE_COMMAND cd <BINARY_DIR> && cmake -D CMAKE_INSTALL_PREFIX=$<INSTALL_DIR> <SOURCE_DIR>
>                    )
> ------------------------------------------------------------------------------
>
>
>
> ----- Mail original -----
>> De: "David Cole" <DLRdave at aol.com>
>> À: "Cedric Doucet" <cedric.doucet at inria.fr>
>> Cc: cmake at cmake.org
>> Envoyé: Lundi 13 Avril 2015 12:40:34
>> Objet: Re: [CMake] Don't download external projects again after calling "make clean"
>>
>> Use the URL_MD5 and DOWNLOAD_DIR arguments to ExternalProject_Add to
>> put the downloaded files into a location outside the build tree
>> (perhaps ~/Downloads on Mac/Linux or $ENV{USERPROFILE}/Downloads on
>> Windows).
>>
>> With DOWNLOAD_DIR outside the build tree, and the checksums of the
>> downloaded files being the same as you've specified via URL_MD5, the
>> download portion will be avoided once there is a local copy of a file
>> available.
>>
>>
>> HTH,
>> David C.
>>
>>
>> On Mon, Apr 13, 2015 at 5:04 AM, Cedric Doucet <cedric.doucet at inria.fr>
>> wrote:
>> >
>> > Hello!
>> >
>> > I use the ExternalProject_Add function to download third-party libraries of
>> > a code.
>> >
>> > Once a library has been downloaded, I can call "make" as many times as I
>> > want without downloading this library again.
>> > It seems that CMake detects that the library has already been downloaded.
>> >
>> > However, calling "make clean" seems to destroy this feature.
>> > Even if my library is not uninstalled during cleaning, calling "make" after
>> > "make clean" will lead CMake to try download the library again.
>> >
>> > How could I tell CMake not to download the library again?
>> >
>> > Thank you very much for your help!
>> >
>> > Cédric
>> >
>> > --
>> >
>> > 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
>>


More information about the CMake mailing list