[CMake] ExternalProject: how to avoid reinstalling after 'make clean'?

Johannes Zarl johannes.zarl at jku.at
Tue Apr 28 06:36:01 EDT 2015


Hi Cedric,

This is something that ExternalProject cannot really do for you in an 
automatic/safe way. When you do a make clean, you wipe out all knowledge about 
the installed package.

However, you can implement this yourself: Before you do the 
ExternalProject_Add(eigen ...) call, you can call find_package(eigen) and if 
you find the package, you just skip the ExternalProject_Add.

Cheers,
  Johannes



On Tuesday 28 April 2015 12:04:50 Cedric Doucet wrote:
> Hello!
> 
> No one knows how to avoid spurious installations with external projects?
> 
> Thank you,
> 
> Cédric
> 
> ----- Mail original -----
> 
> > De: "Cedric Doucet" <cedric.doucet at inria.fr>
> > À: cmake at cmake.org
> > Envoyé: Vendredi 24 Avril 2015 11:35:54
> > Objet: ExternalProject: how to avoid reinstalling after 'make clean'?
> > 
> > Hello,
> > 
> > I use the ExternalProjet_Add function to download and install third-party
> > libraries.
> > Here is an example of a CMakeLists file containing such a call:
> > 
> > =====================================
> > 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 ${CMAKE_CURRENT_BINARY_DIR})
> > 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
> > STAMP_DIR ${EXTERNAL_DIR}/eigen/stamp
> > INSTALL_DIR ${EXTERNAL_DIR}/eigen/install
> > URL http://bitbucket.org/eigen/eigen/get/3.2.4.tar.gz
> > URL_MD5 4d0d77e06fef87b4fcd2c9b72cc8dc55
> > CMAKE_ARGS -D CMAKE_INSTALL_PREFIX=<INSTALL_DIR>
> > )
> > 
> > =====================================
> > 
> > Everything works fine, except after calling "make clean".
> > Thanks to URL_MD5, the third-party library is not downloaded again.
> > However, configuration, build and install steps are performed again
> > whereas
> > the library has not been uninstalled during cleaning.
> > 
> > How could I tell to ExternalProject_Add not to configure/build/install my
> > library unless this library has been removed from my computer?
> > 
> > Thank you very much for your help!
> > 
> > Cédric



More information about the CMake mailing list