[CMake] Optional .cmake files and rebuilding makefiles

Richard Wackerbarth rkw at dataplex.net
Tue Jul 12 12:35:51 EDT 2005


Following Brad's suggestion, I have

SET(HAS_PASSED_MY_TEST 0)
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/Passed_My_Test.cmake OPTIONAL)

IF (NOT HAS_PASSED_MY_TEST)
    ADD_TEST( RunMyTest
       ${CMAKE_CURRENT_BINARY_DIR}/MyTestProgram
        )
ENDIF (NOT HAS_PASSED_MY_TEST)


If the test succeeds, it writes the file
${CMAKE_CURRENT_BINARY_DIR}/Passed_My_Test.cmake
as
SET(HAS_PASSED_MY_TEST 1)

The next time that cmake runs, the test is suppressed until I clean  
out the binary directory tree.
This is just what I want to happen.

My problem is that it takes some additional change to get cmake to run.
If I run the test and have no other changes, the next run still  
includes the test because nothing triggers cmake to run.
But as soon as I change some other CMakeList.txt file, cmake runs and  
rebuilds the makefiles to suppress the test.

How can I set up a dependency which both tolerates the non-existence  
of "Passed_My_Test.cmake" and triggers the rebuilding of the  
makefiles when this file is created or changes?



More information about the CMake mailing list