SET(CUTER_TEST_DRIVER CUTer_test_driver) SET(CUTER_TEST_PASSED "Passed") SET(CUTER_TEST_FAILED "Failed") # Create a driver for the CUTer tests # E.g. CREATE_CUTER_TEST_DRIVER(test_driver.c) MACRO(CREATE_CUTER_TEST_DRIVER _driver_file _test_sources _libraries) # Create a simple driver FILE(WRITE ${_driver_file} "/* ${_driver_file} */\n") FILE(APPEND ${_driver_file} "/* automatically generated by cmake */\n\n") FILE(APPEND ${_driver_file} "#include \n") FILE(APPEND ${_driver_file} "STANDALONE\n") # Add the tests to build the executable ADD_EXECUTABLE(${CUTER_TEST_DRIVER} ${_driver_file} ${_test_sources}) # Link to CUTer TARGET_LINK_LIBRARIES(${CUTER_TEST_DRIVER} CUTer ${_libraries}) ENDMACRO(CREATE_CUTER_TEST_DRIVER) MACRO(ENABLE_CUTER_TESTING _source_dir) # If test_driver has been built, get the tests and add them IF(EXISTS ${_source_dir}/${CUTER_TEST_DRIVER}) # Make the test list EXECUTE_PROCESS(COMMAND ${_source_dir}/${CUTER_TEST_DRIVER} -l OUTPUT_VARIABLE _tests) # Convert string to list SEPARATE_ARGUMENTS(_tests) # Now add them all to the test framework if test_driver exists FOREACH(_name ${_tests}) ADD_TEST(${_name} ${CUTER_TEST_DRIVER} ${_name}) SET_TESTS_PROPERTIES(${_name} PROPERTIES PASS_REGULAR_EXPRESSION ${CUTER_TEST_PASSED}) SET_TESTS_PROPERTIES(${_name} PROPERTIES FAIL_REGULAR_EXPRESSION ${CUTER_TEST_FAILED}) ENDFOREACH(_name ${_tests}) ELSE(EXISTS ${_source_dir}/${CUTER_TEST_DRIVER}) MESSAGE(STATUS "NOTE: To enable testing run: make ${CUTER_TEST_DRIVER}; cmake .") ENDIF(EXISTS ${_source_dir}/${CUTER_TEST_DRIVER}) ENDMACRO(ENABLE_CUTER_TESTING _source_dir)