[CMake] How do I use the ExternalProject module to compile only once

Delcypher delcypher at gmail.com
Thu Dec 22 08:58:15 EST 2011


Apologies. There was a silly mistake in the version posted on
pastebin. Here is a corrected version http://pastebin.com/P95WNUP5

The problems I see with what I have written are:

* The line "FIND_PACKAGE(ITK)" when FETCH_ITK is enabled is making
things go wrong because the ITK library hasn't been downloaded yet.
* Even if the above point wasn't a problem. When I run "cmake ../src/"
again this isn't going to create a makefile that does what I want. The
ITK library will downloaded all over again and then built.

Any thoughts?

Thanks,
Dan.

On 22 December 2011 13:40, Delcypher <delcypher at gmail.com> wrote:
> Hi,
>
> I'm starting work on a project that depends on the ITK library and I'm
> using Arch Linux as my build platform. What I'd like to be able to do
> is the following.
>
> * When the following is run
> $ pwd
> /home/dan/project/build-dir
> $ cmake ../src/
>
> for there to be a variable to be set it the cache (call it FETCH_ITK)
> that allows the user to pick between building the ITK library or try
> to use the system ITK library. Once the makefile is generated
> I would like this to happen when make is executed.
>
> - If the user picked to build the ITK library and it HAS NOT been built then
> the ExternalProject module is used to fetch and build ITK and then the
> rest of the project is built.
>
> -If the user picked to build ITK and it HAS already been built then my
> project is built WITHOUT attempting to rebuild the ITK library. With
> ITK_DIR set appropriately so that FIND_PACKAGE(ITK) works.
>
> -If the user picked to not build ITK then my project is built. With
> ITK_DIR not set to anything so that FIND_PACKAGE(ITK) works.
>
> I'm afraid I'm very new to cmake and I'm not quite sure how to do
> this. I made a start which can be seen here
> http://pastebin.com/xwiFPrY5
>
> However it doesn't work. The ExternalProject() code seemed to work
> okay in isolation but when I added everything else it didn't work.
>
> Any suggestions?
>
> Thanks,
> Dan.


More information about the CMake mailing list