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