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

Delcypher delcypher at gmail.com
Thu Dec 22 08:40:29 EST 2011


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