[CMake] ExternalProject: avoiding rebuilds

kent williams nkwmailinglists at gmail.com
Mon Sep 26 17:28:48 EDT 2011


In general it's better to make your project into an ExternalProject
itself, and have it depend on all other ExternalProject upon which it
depends.

That way all prerequisites get built, and then your package get built.
 It ensures that all prerequisites are fully built and installed
before your project is configured.

You can specify DOWNLOAD_COMMAND as "" and set SOURCE_DIR to your
project's source directory, in which case ExternalProject_add doesn't
try and download your source.

Slicer has a trick for doing this with a single top-level
CMakeLists.txt that works like this

option(Do_SuperBuild "Build all prerequisites and this project" ON)

if(Do_SuperBuild)
# build prerequisites...
Project(SuperBuild)
#now build this project
ExternalProjectAdd(MyProject
DEPENDS dependency_list
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
CMAKE_ARGS -DDo_SuperBuild:BOOL=OFF
)
else(Do_SuperBuild)
#
# all the CMake stuff to build your program

endif(Do_SuperBuild)

On Mon, Sep 26, 2011 at 12:45 PM, Rolf Eike Beer <eike at sf-mail.de> wrote:
> Am Montag, 26. September 2011, 10:37:57 schrieb Ben Medina:
>> John is right. The external project may be at the bottom of a chain of
>> (my own) project dependencies. I need to preserve the ability to
>> easily rebuild just my projects (and their dependencies), not external
>> projects. Think of ExternalProject as a replacement for pre-built
>> libraries, and you'll see where I'm coming from.
>>
>> Perhaps I need to file a feature request on Mantis.
>
> You may try, but I don't think that this will help. AFAICT this "clean and
> then rebuild" stuff is a Visual Studio thing.
>
> 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
>


More information about the CMake mailing list