[CMake] How to rerun tests after failure?

Eduard Bloch edi at gmx.de
Sat Oct 6 19:37:26 EDT 2007


Hello,

this is maybe a stupid question but I could not find any usefull way to
solve this simple problem. 

Use case: a test using CheckCXXSourceCompiles module. When everything is
alright, it runs once and detects all the stuff (this is okay). If not,
test exists with a FATAL_ERROR message telling user how to fix the
environment. The users reads the output and follows the advice.

Expected results: type "cmake ." again and it shall continue and rerun
the last failed test and continue from there.

Real results: The failed test is (silently) skipped. The old (failed)
result seems to be taken from the cache instead -> user confusion.

I tried unsetting the variable of the last check before printing the
fatal message, nothing did help. AFAICS the output value of
CHECK_CXX_SOURCE_COMPILES is always stored in the cache as INTERNAL
entry.

Is there any good way to get rid of it? Except of purging whole cache
every time when CMake is started, of course.

Sample test case attached.

Regards,
Eduard.

SET(CMAKE_REQUIRED_LIBRARIES bz2)
SET(TESTSRC "
#include <bzlib.h>
bz_stream t; int main(){ return BZ2_bzDecompressInit(&t, 1, 0); }
")
CHECK_CXX_SOURCE_COMPILES("${TESTSRC}" HAS_LIBBZ2)
IF(NOT HAS_LIBBZ2)
   # doesn't help MARK_AS_ADVANCED(HAS_LIBBZ2)
   SET(HAS_LIBBZ2 ) # doesn't help
   MESSAGE(FATAL_ERROR "Unable to use libbz2 development components. Install libbz2-dev.")
ENDIF(NOT HAS_LIBBZ2)




More information about the CMake mailing list