You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

runtest.cmake 1.3 kB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Replace INTDIR with the value of $ENV{CMAKE_CONFIG_TYPE} that is set
  2. # by ctest when -C Debug|Releaes|etc is given, and INDIR is passed
  3. # in from the main cmake run and is the variable that is used
  4. # by the build system to specify the build directory
  5. if(NOT "${INTDIR}" STREQUAL ".")
  6. set(TEST_ORIG "${TEST}")
  7. string(REPLACE "${INTDIR}" "$ENV{CMAKE_CONFIG_TYPE}" TEST "${TEST}")
  8. if("$ENV{CMAKE_CONFIG_TYPE}" STREQUAL "")
  9. if(NOT EXISTS "${TEST}")
  10. message("Warning: CMAKE_CONFIG_TYPE not defined did you forget the -C option for ctest?")
  11. message(FATAL_ERROR "Could not find test executable: ${TEST_ORIG}")
  12. endif()
  13. endif()
  14. endif()
  15. set(ARGS )
  16. if(DEFINED OUTPUT)
  17. set(ARGS OUTPUT_FILE "${OUTPUT}" ERROR_FILE "${OUTPUT}.err")
  18. endif()
  19. if(DEFINED INPUT)
  20. list(APPEND ARGS INPUT_FILE "${INPUT}")
  21. endif()
  22. message("Running: ${TEST}")
  23. message("ARGS= ${ARGS}")
  24. execute_process(COMMAND "${TEST}"
  25. ${ARGS}
  26. RESULT_VARIABLE RET)
  27. if(DEFINED OUTPUT)
  28. file(READ "${OUTPUT}" TEST_OUTPUT)
  29. file(READ "${OUTPUT}.err" TEST_ERROR)
  30. message("Test OUTPUT:\n${TEST_OUTPUT}")
  31. message("Test ERROR:\n${TEST_ERROR}")
  32. endif()
  33. # if the test does not return 0, then fail it
  34. if(NOT ${RET} EQUAL 0)
  35. message(FATAL_ERROR "Test ${TEST} returned ${RET}")
  36. endif()
  37. message( "Test ${TEST} returned ${RET}")