ctkMacroSimpleTest.cmake 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #! Usage:
  2. #! \code
  3. #! SIMPLE_TEST(<testname> [argument1 ...])
  4. #! \endcode
  5. #!
  6. #! This macro add a test using the complete add_test signature specifying target using
  7. #! $<TARGET_FILE:...> generator expression. Optionnal test argument(s) can be passed
  8. #! after specifying the <testname>.
  9. #!
  10. #! Variable named KIT is expected to be defined in the current scope. KIT variable usually
  11. #! matches the value of PROJECT_NAME.
  12. #!
  13. #! The macro also associates a label to the test based on the current value of KIT.
  14. #!
  15. #! \sa http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:add_test
  16. #! \sa http://www.cmake.org/cmake/help/cmake-2-8-docs.html#variable:PROJECT_NAME
  17. #!
  18. #! \ingroup CMakeUtilities
  19. macro(SIMPLE_TEST testname)
  20. if("${KIT}" STREQUAL "")
  21. message(FATAL_ERROR "error: KIT variable is not set !")
  22. endif()
  23. if(NOT TARGET ${KIT}CppTests)
  24. message(FATAL_ERROR "error: ${KIT}CppTests target does NOT exist !")
  25. endif()
  26. add_test(NAME ${testname} COMMAND $<TARGET_FILE:${KIT}CppTests> ${testname} ${ARGN})
  27. set_property(TEST ${testname} PROPERTY LABELS ${KIT})
  28. endmacro()