CMakeLists.txt 5.92 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145

# Include Testing package
INCLUDE(CTest)


if(BUILD_TESTING)

SET (CTEST_DROP_SITE_CDASH FALSE)

  # ========================================================================
  # Copy converter files from ctest output to correctly generate xml output
  # ========================================================================
  if ( WIN32 )	

    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/run_tests.bat
      ${CMAKE_BINARY_DIR}/tests/run_tests.bat COPYONLY)

    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/head.bat
      ${CMAKE_BINARY_DIR}/tests/head.bat COPYONLY)

  else(WIN32)

    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/run_tests.sh 
      ${CMAKE_BINARY_DIR}/tests/run_tests.sh COPYONLY)

  endif()

  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/globalTestFiles/cube1.obj
    ${OPENFLIPPER_TEST_FILES}/cube1.obj COPYONLY)


  make_directory(${OPENFLIPPER_TEST_RESULTS})
  make_directory(${OPENFLIPPER_TEST_BINARIES})

  # ========================================================================
  # ========================================================================
  # ========================================================================
  # Run OpenMesh tests
  # ========================================================================
  # ========================================================================
  # ========================================================================


  if ( NOT DEFINED OPENFLIPPER_BUILD_UNIT_TESTS )
    set( OPENFLIPPER_BUILD_UNIT_TESTS false CACHE BOOL "Enable or disable unit tests on all integrated libraries." )
  endif()

  if ( OPENFLIPPER_BUILD_UNIT_TESTS ) 

    #enable the OpenMesh unit tests
    set (OPENMESH_BUILD_UNIT_TESTS true CACHE BOOL "Enable or disable unit test builds in OpenMesh.")

    #enable the ACG unit tests
    set (ACG_BUILD_UNIT_TESTS true CACHE BOOL "Enable or disable unit test builds in ACG.")


    find_package(GoogleTest)

    if(GTEST_FOUND)
      add_subdirectory(${CMAKE_SOURCE_DIR}/OpenFlipper/libs_required/OpenMesh/src/Unittests ${CMAKE_BINARY_DIR}/OpenFlipper/libs_required/OpenMesh/src/Unittests)
    endif()

  endif()

  # ========================================================================
  # ========================================================================
  # Internal global tests start here
  # ========================================================================
  # ========================================================================


  # ========================================================================
  # ========================================================================
  # ========================================================================
  # Add tests from subdirectories
  # ========================================================================
  # ========================================================================
  # ========================================================================
  
  # search all libs in the libs directory 
  file (
    GLOB _local_tests_in
    RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
        "${CMAKE_CURRENT_SOURCE_DIR}/*/CMakeLists.txt"
        
  )

  # add all found tests to the build
  foreach (_localTest ${_local_tests_in})
    get_filename_component (_local_test_dir ${_localTest} PATH)
    add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR}/${_local_test_dir})
  endforeach ()

  # ========================================================================
  # ========================================================================
  # ========================================================================
  # Start OpenFlipper Headless in batch mode, to see if all plugins
  # that pretend to be scriptable without ui are correct and the core
  # can start
  # ========================================================================
  # ========================================================================
  # ========================================================================

  ADD_TEST(BatchStart "${OPENFLIPPER_EXECUTABLE}" -b -c )

  # Timeout after 60 seconds if we havean endless loop
  # Should be run serial to avoid collisons with other instances
  # Only one processor required
  set_tests_properties (
      BatchStart PROPERTIES
      TIMEOUT 180
      RUN_SERIAL TRUE
      PROCESSORS 1
  ) 

  # ========================================================================
  # ========================================================================
  # ========================================================================
  # Add tests from plugins
  # ========================================================================
  # ========================================================================
  # ========================================================================

  file (
      GLOB _plugins_in
      RELATIVE "${CMAKE_SOURCE_DIR}"
      "${CMAKE_SOURCE_DIR}/Plugin-*/CMakeLists.txt"
      "${CMAKE_SOURCE_DIR}/PluginCollection-*/Plugin-*/CMakeLists.txt"
      "${CMAKE_SOURCE_DIR}/Package-*/Plugin-*/CMakeLists.txt"
      "${CMAKE_SOURCE_DIR}/Package-*/PluginCollection-*/Plugin-*/CMakeLists.txt"
  )

  foreach (_plugin ${_plugins_in})

    get_filename_component (_plugin_dir ${_plugin} PATH)

     # If a test subdir exists, we add it here
    if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/${_plugin_dir}/tests)

      # Only get the plugins name without possible collection:
      string (REGEX MATCH "Plugin-.+[/\\]?$" _plugin_name ${_plugin_dir})

      add_subdirectory(${CMAKE_SOURCE_DIR}/${_plugin_dir}/tests ${CMAKE_BINARY_DIR}/tests/${_plugin_name} )
    endif()

Jan Möbius's avatar
Jan Möbius committed
146
147
148
149
150
151
152
153
154
155
156
     # If a PythonTests subdir exists, we add it here
    if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/${_plugin_dir}/PythonTests)

      # Only get the plugins name without possible collection:
      string (REGEX MATCH "Plugin-.+[/\\]?$" _plugin_name ${_plugin_dir})

      add_subdirectory(${CMAKE_SOURCE_DIR}/${_plugin_dir}/PythonTests ${CMAKE_BINARY_DIR}/PythonTests/${_plugin_name} )
    endif()



157
158
159
   endforeach ()

endif()