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