Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkTestPluginGenerator.cmake
Go to the documentation of this file.
1 if(BUILD_TESTING)
2 
3  set(proj GP) # Means GenerateProject (use a short name due to Windows limitations)
4  set(test_project_out_dir "${MITK_BINARY_DIR}")
5  set(test_project_source_dir "${MITK_BINARY_DIR}/${proj}")
6  set(test_project_binary_dir "${MITK_BINARY_DIR}/${proj}-bin")
7 
8  add_test(NAME mitkPluginGeneratorCleanTest
9  COMMAND ${CMAKE_COMMAND} -E remove_directory "${test_project_source_dir}"
10  )
11  set_tests_properties(mitkPluginGeneratorCleanTest PROPERTIES
12  LABELS "MITK;BlueBerry")
13 
14  add_test(NAME mitkPluginGeneratorCleanTest2
15  COMMAND ${CMAKE_COMMAND} -E remove_directory "${test_project_binary_dir}"
16  )
17  set_tests_properties(mitkPluginGeneratorCleanTest2 PROPERTIES
18  LABELS "MITK;BlueBerry")
19 
20  add_test(NAME mitkPluginGeneratorCleanTest3
21  COMMAND ${CMAKE_COMMAND} -E make_directory "${test_project_binary_dir}"
22  )
23  set_tests_properties(mitkPluginGeneratorCleanTest3 PROPERTIES
24  DEPENDS mitkPluginGeneratorCleanTest2
25  LABELS "MITK;BlueBerry")
26 
27  add_test(NAME mitkPluginGeneratorCreateTest
28  COMMAND ${exec_target} --project-name "${proj}" --project-app-name "TestApp"
29  -ps org.test.plugin -pn "Test Plugin" -vn "Test View"
30  -o ${test_project_out_dir} -y -n
31  )
32  set_tests_properties(mitkPluginGeneratorCreateTest PROPERTIES
33  DEPENDS "${exec_target};mitkPluginGeneratorCleanTest;mitkPluginGeneratorCleanTest3"
34  LABELS "MITK;BlueBerry")
35 
36  set(configure_options
37  -DMITK_DIR:PATH=${MITK_BINARY_DIR}
38  -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
39  -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
40  -DCMAKE_OSX_SYSROOT:PATH=${CMAKE_OSX_SYSROOT}
41  -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET}
42  -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES}
43  -G${CMAKE_GENERATOR}
44  -C "${MITK_BINARY_DIR}/mitkTestInitialCache.txt"
45  )
46 
47  if(CMAKE_PREFIX_PATH)
48  string (REPLACE ";" "$<SEMICOLON>" CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}")
49  list(APPEND configure_options -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH})
50  endif()
51 
52  if(CMAKE_CONFIGURATION_TYPES)
53  foreach(config ${CMAKE_CONFIGURATION_TYPES})
54  add_test(NAME mitkPluginGeneratorConfigureTest-${config} CONFIGURATIONS ${config}
55  WORKING_DIRECTORY "${test_project_binary_dir}"
56  COMMAND ${CMAKE_COMMAND} ${configure_options}
57  "${test_project_source_dir}")
58  set_tests_properties(mitkPluginGeneratorConfigureTest-${config} PROPERTIES
59  DEPENDS mitkPluginGeneratorCreateTest
60  LABELS "MITK;BlueBerry")
61 
62  add_test(NAME mitkPluginGeneratorBuildTest-${config} CONFIGURATIONS ${config}
63  COMMAND ${CMAKE_COMMAND} --build ${test_project_binary_dir} --config ${config})
64  set_tests_properties(mitkPluginGeneratorBuildTest-${config} PROPERTIES
65  DEPENDS mitkPluginGeneratorConfigureTest-${config}
66  LABELS "MITK;BlueBerry")
67  endforeach()
68  else()
69  add_test(NAME mitkPluginGeneratorConfigureTest-${CMAKE_BUILD_TYPE}
70  WORKING_DIRECTORY "${test_project_binary_dir}"
71  COMMAND ${CMAKE_COMMAND} ${configure_options}
72  -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
73  "${test_project_source_dir}")
74  set_tests_properties(mitkPluginGeneratorConfigureTest-${CMAKE_BUILD_TYPE} PROPERTIES
75  DEPENDS mitkPluginGeneratorCreateTest
76  LABELS "MITK;BlueBerry")
77 
78  add_test(NAME mitkPluginGeneratorBuildTest-${CMAKE_BUILD_TYPE}
79  COMMAND ${CMAKE_COMMAND} --build ${test_project_binary_dir} --config ${CMAKE_BUILD_TYPE})
80  set_tests_properties(mitkPluginGeneratorBuildTest-${CMAKE_BUILD_TYPE} PROPERTIES
81  DEPENDS mitkPluginGeneratorConfigureTest-${CMAKE_BUILD_TYPE}
82  LABELS "MITK;BlueBerry")
83  endif()
84 
85  set(package_test_configurations)
86  if(WIN32)
87  # Only test packaging if build type is "Release" on Windows
88  set(package_test_configurations CONFIGURATIONS Release)
89  endif()
90 
91  if(NOT MITK_FAST_TESTING)
92 
93  if(WIN32)
94  # Only test packaging if build type is "Release" on Windows
95  add_test(NAME mitkPluginGeneratorPackageTest CONFIGURATIONS Release
96  COMMAND ${CMAKE_COMMAND} --build ${test_project_binary_dir}/${proj}-build --config Release --target package)
97  set_tests_properties(mitkPluginGeneratorPackageTest PROPERTIES
98  DEPENDS mitkPluginGeneratorBuildTest-Release
99  TIMEOUT 6000
100  LABELS "MITK;BlueBerry;PACKAGE_TESTS")
101  elseif(CMAKE_BUILD_TYPE)
102  add_test(mitkPluginGeneratorPackageTest
103  ${CMAKE_COMMAND} --build ${test_project_binary_dir}/${proj}-build --config ${CMAKE_BUILD_TYPE} --target package)
104  set_tests_properties(mitkPluginGeneratorPackageTest PROPERTIES
105  DEPENDS mitkPluginGeneratorBuildTest-${CMAKE_BUILD_TYPE}
106  TIMEOUT 6000
107  LABELS "MITK;BlueBerry;PACKAGE_TESTS")
108  endif()
109 
110  endif()
111 
112 endif()
113