[CMake] A "How to" Question

Brad King brad.king at kitware.com
Thu Jul 7 10:37:11 EDT 2005


Richard Wackerbarth wrote:
> I'm porting some programs to a number of platforms. The only access  
> that I have to some of those platforms is the results of a Nightly  
> dashboard.
> In most cases, the difficulties are in the compile phase. I have some  
> short "sanity checks" that I can run as tests. However, the real  tests 
> are quite lengthy.
> Because the progress on various platforms varies, I'd like to try to  
> run the long test each time only until it passes. Then, I would like  to 
> stop running it on that platform for a while.
> 
> If I were doing this with standard Unix makefiles, I would have a  
> target (in the intermediate files area) that I can clean, perhaps  
> semi-monthly, to rerun the long tests.
> 
> 
> TestPassed: Executable
>     make RecordTestResult
> 
> RecordTestResult: RunTest
>     touch TestPassed
> 
> RunTest: ClearTestPassed
>     Executable -options Testfiles
> 
> ClearTestPassed:
>     rm TestPassed
> 
> clean: ClearTestPassed
> 
> Of course, when I do run the test, I want the results posted as a  part 
> of the dashboard
> How would you suggest to do this in CMake?

You can use a variable to decide whether to add the test:

SET(DO_MY_TEST 1)
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/MyTestBlock.cmake OPTIONAL)
IF(DO_MY_TEST)
   ADD_TEST(mytest ...)
ENDIF(DO_MY_TEST)

Then the test can write out the file MyTestBlock.cmake with the contents

SET(DO_MY_TEST 0)

when it passes.  A separate cron job or scheduled task could then remove 
the MyTestBlock.cmake file at some scheduled interval.

-Brad


More information about the CMake mailing list