[CMake] ExternalProject: avoiding rebuilds

Ben Medina ben.medina at gmail.com
Fri Sep 23 19:26:46 EDT 2011


Hello all,

I'm trying to adopt greater usage of ExternalProject in my project.
One problem I'd like to resolve is spurious rebuilds of external
projects.

For example, I'd like to build CLAPACK as an external project, so I do
something like this:

ExternalProject_Add (clapack
    URL ${tarball_location}
    URL_MD5 4fd18eb33f3ff8c5d65a7d43913d661b
    UPDATE_COMMAND ""
    CMAKE_CACHE_ARGS "${clapack_cmake_args}"
    INSTALL_COMMAND ""
    )

add_executable (test main.cpp)

add_dependencies(test clapack)

This works great: building "test" first untars the CLAPACK source and
builds it, as expected. However, if I rebuild test (i.e. in Visual
Studio, right-click on test and rebuild), then the CLAPACK tarball get
extracted *again*, and a full rebuild of CLAPACK happens. I'd expect
that, unless the tarball is changed, a rebuild of the external project
is a no-op.

Is there a way to achieve my desired behavior?

I have another external project where the source is checked into my
source tree. A rebuild on that external project is a no-op unless the
source files have changed. However, I'd rather avoid checking in
3rdparty source code into my source tree.

Thanks,
Ben


More information about the CMake mailing list