[CMake] example of ctest --build-and-test

Brad King brad.king at kitware.com
Mon Oct 16 14:08:05 EDT 2006


Luigi Calori wrote:
> I have the following problem:
> a master cmake project that wants to configure and build a series of
> slave cmake projects
> I' ve tried several hacking but not found an elegant solution.
> I' ve read from the list that the
> 
> ctest --build-and-test
> 
> 
> could be used for that but did not found any example: any suggestion?
> The main reason for such a request is that I would like to have targets
> that download from CVS,configure and build projects, so to
> use the master build phase as a kind of interface to all the tedious
> step of grabbibg things from the net, configuring and building.
> Are there any examples ?

All the CMake tests are run with build-and-test:

http://www.cmake.org/cgi-bin/viewcvs.cgi/Source/CMakeLists.txt?rev=1.301&root=CMake&view=markup

VTK uses build-and-test to build an examples sub-project in a custom target:

http://www.vtk.org/cgi-bin/viewcvs.cgi/Examples/CMakeLists.txt?rev=1.31&view=markup

Look near the lines

  ADD_CUSTOM_COMMAND(
    OUTPUT ${VTK_BINARY_DIR}/VTKExamples

You could also consider making this one big build tree.  You can use
EXECUTE_PROCESS to run programs to get things from the net and extract
the source trees.  Then just use ADD_SUBDIRECTORY to include the source
trees in your build.  A bit more complication may be needed to not get
the source over and over.  Using IF(FILE_IS_NEWER) may help.

-Brad


More information about the CMake mailing list