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

Benjamin Eikel cmake at eikel.org
Thu Dec 22 09:04:16 EST 2011


Hello,

Am Donnerstag, 22. Dezember 2011, 14:58:15 schrieb Delcypher:
> 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?

maybe have a look at the KDE SuperBuild [1]. It uses a file called 
"ThisIsASourcePackage.valid" to determine if the build is done from a source 
package, or if the source has to be downloaded.

Kind regards
Benjamin

[1] 
https://projects.kde.org/projects/kde/superbuild/repository/revisions/master/entry/SuperBuild.cmake


> 
> 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.
> 
> --
> 
> 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