CMakeLists.txt 10.8 KB
Newer Older
1 2 3
if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
  CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
endif ()
4

5 6
PROJECT(QtTesting)

7 8 9 10 11
IF(NOT DEFINED QtTesting_QT_VERSION)
  SET(QtTesting_QT_VERSION "4" CACHE STRING "Expected Qt version")
  MARK_AS_ADVANCED(QtTesting_QT_VERSION)
  SET_PROPERTY(CACHE QtTesting_QT_VERSION PROPERTY STRINGS 4 5)
ENDIF()
12 13 14 15 16
IF(NOT (QtTesting_QT_VERSION VERSION_EQUAL "4" OR
  QtTesting_QT_VERSION VERSION_EQUAL "5"))
  message(FATAL_ERROR "Expected value for QtTesting_QT_VERSION is either '4' or '5'")
ENDIF()

17
set(qt_imported_targets)
18
IF(QtTesting_QT_VERSION VERSION_GREATER "4")
19 20
  FIND_PACKAGE(Qt5 REQUIRED COMPONENTS Core Widgets)
  SET(qt_imported_targets Qt5::Core Qt5::Widgets)
21
ELSE()
22 23
  FIND_PACKAGE(Qt4 REQUIRED COMPONENTS QtGui)
  SET(qt_imported_targets Qt4::QtCore Qt4::QtGui)
24 25 26 27 28 29 30 31 32 33
ENDIF()

IF(NOT DEFINED QT_TESTING_WITH_PYTHON)
  OPTION(QT_TESTING_WITH_PYTHON "Enable Qt Testing with Python" OFF)
ENDIF()

IF(NOT DEFINED QtTesting_INSTALL_BIN_DIR)
  SET(QtTesting_INSTALL_BIN_DIR bin)
ENDIF()

Matthew Woehlke's avatar
Matthew Woehlke committed
34 35 36 37
IF(NOT DEFINED QtTesting_INSTALL_INCLUDE_DIR)
  SET(QtTesting_INSTALL_INCLUDE_DIR include/QtTesting)
ENDIF()

38 39 40
IF(NOT DEFINED QtTesting_INSTALL_LIB_DIR)
  SET(QtTesting_INSTALL_LIB_DIR lib)
ENDIF()
41

42
IF(NOT DEFINED QtTesting_INSTALL_CMAKE_DIR)
43
  SET(QtTesting_INSTALL_CMAKE_DIR lib/cmake/qttesting)
44
ENDIF()
45

46 47 48 49 50
IF(NOT DEFINED QT_TESTING_EVENT_PLAYBACK_DELAY)
  SET(QT_TESTING_EVENT_PLAYBACK_DELAY "100" CACHE STRING "Delay between invocation of each testing event." FORCE)
  MARK_AS_ADVANCED(QT_TESTING_EVENT_PLAYBACK_DELAY)
ENDIF()

David Partyka's avatar
David Partyka committed
51 52 53 54
IF(NOT QT_TESTING_INSTALL_EXPORT_NAME)
  SET(QT_TESTING_INSTALL_EXPORT_NAME QtTestingTargets)
ENDIF()

55 56 57 58 59 60 61 62 63 64
# One can define QT_TESTING_CUSTOM_LIBRARY_PREFIX and/or
# QT_TESTING_CUSTOM_LIBRARY_SUFFIX to add prefix/suffix to libraries
# generated by thus project. Default is empty.
if(NOT DEFINED QT_TESTING_CUSTOM_LIBRARY_SUFFIX)
  set(QT_TESTING_CUSTOM_LIBRARY_SUFFIX)
endif()
if(NOT DEFINED QT_TESTING_CUSTOM_LIBRARY_PREFIX)
  set(QT_TESTING_CUSTOM_LIBRARY_PREFIX)
endif()

65
IF(QT_TESTING_WITH_PYTHON)
66

67 68 69
  IF(NOT PythonLibs_FOUND)
    FIND_PACKAGE(PythonLibs REQUIRED)
  ENDIF()
70

71 72 73 74 75 76 77 78 79
  IF(UNIX)
    FIND_LIBRARY(PYTHON_UTIL_LIBRARY
      NAMES util
      PATHS /usr/lib
      DOC "Utility library needed for vtkpython"
      )
    MARK_AS_ADVANCED(PYTHON_UTIL_LIBRARY)
    IF(PYTHON_UTIL_LIBRARY)
      SET(PYTHON_UTIL_LIBRARY_LIB ${PYTHON_UTIL_LIBRARY})
80 81
    ENDIF()
  ENDIF()
82

83 84 85 86 87
  INCLUDE_DIRECTORIES(
    ${PYTHON_INCLUDE_PATH}
  )
  SET(PYTHON_MOCS
    pqPythonEventObserver.h
88
    pqPythonEventSource.h
89 90 91 92 93 94 95
  )
  SET(PYTHON_SRCS
    pqPythonEventObserver.cxx
    pqPythonEventObserver.h
    pqPythonEventSource.cxx
    pqPythonEventSource.h
  )
96
ENDIF(QT_TESTING_WITH_PYTHON)
97

98 99 100 101 102 103 104 105 106 107
INCLUDE_DIRECTORIES(
  ${QtTesting_BINARY_DIR}
  ${QtTesting_SOURCE_DIR}
)

# Reduce the number of dirs that get included on moc command line
# since it causes issues on Windows 2000.
GET_DIRECTORY_PROPERTY(include_dirs_tmp INCLUDE_DIRECTORIES)
SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES "${MOC_INCLUDE_DIRS}")

108
SET(MOC_SRCS
109
  pq3DViewEventPlayer.h
Mathieu Westphal's avatar
Mathieu Westphal committed
110
  pq3DViewEventTranslator.h
111 112
  pqAbstractActivateEventPlayer.h
  pqAbstractBooleanEventPlayer.h
Mathieu Westphal's avatar
Mathieu Westphal committed
113
  pqAbstractButtonEventTranslator.h
114 115 116
  pqAbstractDoubleEventPlayer.h
  pqAbstractIntEventPlayer.h
  pqAbstractItemViewEventPlayer.h
Mathieu Westphal's avatar
Mathieu Westphal committed
117
  pqAbstractItemViewEventPlayerBase.h
118
  pqAbstractItemViewEventTranslator.h
Mathieu Westphal's avatar
Mathieu Westphal committed
119
  pqAbstractItemViewEventTranslatorBase.h
120
  pqAbstractMiscellaneousEventPlayer.h
121
  pqAbstractSliderEventTranslator.h
122 123
  pqAbstractStringEventPlayer.h
  pqBasicWidgetEventPlayer.h
Mathieu Westphal's avatar
Mathieu Westphal committed
124 125
  pqBasicWidgetEventTranslator.h
  pqCheckEventOverlay.h
126
  pqComboBoxEventTranslator.h
Mathieu Westphal's avatar
Mathieu Westphal committed
127
  pqComboBoxEventPlayer.h
128
  pqCommentEventPlayer.h
129
  pqDoubleSpinBoxEventTranslator.h
130
  pqEventComment.h
131
  pqEventDispatcher.h
132
  pqEventObserver.h
133
  pqEventPlayer.h
Mathieu Westphal's avatar
Mathieu Westphal committed
134
  pqEventRecorder.h
135
  pqEventSource.h
136 137
  pqEventTranslator.h
  pqLineEditEventTranslator.h
138 139
  pqListViewEventPlayer.h
  pqListViewEventTranslator.h
140
  pqMenuEventTranslator.h
141
  pqNativeFileDialogEventPlayer.h
142
  pqNativeFileDialogEventTranslator.h
143
  pqPlayBackEventsDialog.h
144 145
  pqRecordEventsDialog.h
  pqSpinBoxEventTranslator.h
146
  pqStdoutEventObserver.h
147
  pqTabBarEventPlayer.h
148
  pqTabBarEventTranslator.h
Mathieu Westphal's avatar
Mathieu Westphal committed
149 150
  pqTableViewEventPlayer.h
  pqTableViewEventTranslator.h
151
  pqTestUtility.h
152
  pqThreadedEventSource.h
153
  pqTimer.h
154
  pqTreeViewEventPlayer.h
155
  pqTreeViewEventTranslator.h
156
  pqWidgetEventPlayer.h
Mathieu Westphal's avatar
Mathieu Westphal committed
157
  pqWidgetEventTranslator.h
158 159
)

160 161 162 163 164 165 166 167 168 169 170 171
IF(QtTesting_QT_VERSION VERSION_GREATER "4")
  QT5_WRAP_CPP(MOC_BUILT_SOURCES
    ${MOC_SRCS}
    ${PYTHON_MOCS}
  )
ELSE()
  QT4_WRAP_CPP(MOC_BUILT_SOURCES
    ${MOC_SRCS}
    ${PYTHON_MOCS}
  )
ENDIF()

172 173
SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES "${include_dirs_tmp}")

174 175
IF(QtTesting_QT_VERSION VERSION_GREATER "4")
  QT5_WRAP_UI(UI_BUILT_SOURCES
176
    pqPlayBackEventsDialog.ui
177 178 179 180
    pqRecordEventsDialog.ui
  )
ELSE()
  QT4_WRAP_UI(UI_BUILT_SOURCES
181
    pqPlayBackEventsDialog.ui
182 183 184
    pqRecordEventsDialog.ui
  )
ENDIF()
185

186 187 188 189 190 191 192 193 194
IF(QtTesting_QT_VERSION VERSION_GREATER "4")
  QT5_ADD_RESOURCES(QRC_BUILT_SOURCES
    Resources/QtTesting.qrc
  )
ELSE()
  QT4_ADD_RESOURCES(QRC_BUILT_SOURCES
    Resources/QtTesting.qrc
  )
ENDIF()
195

Matthew Woehlke's avatar
Matthew Woehlke committed
196
SET(QtTesting_SOURCES
197 198
  pq3DViewEventPlayer.cxx
  pq3DViewEventTranslator.cxx
199 200 201 202 203 204
  pqAbstractActivateEventPlayer.cxx
  pqAbstractBooleanEventPlayer.cxx
  pqAbstractButtonEventTranslator.cxx
  pqAbstractDoubleEventPlayer.cxx
  pqAbstractIntEventPlayer.cxx
  pqAbstractItemViewEventPlayer.cxx
Mathieu Westphal's avatar
Mathieu Westphal committed
205
  pqAbstractItemViewEventPlayerBase.cxx
206
  pqAbstractItemViewEventTranslator.cxx
Mathieu Westphal's avatar
Mathieu Westphal committed
207
  pqAbstractItemViewEventTranslatorBase.cxx
208
  pqAbstractMiscellaneousEventPlayer.cxx
209 210 211 212
  pqAbstractSliderEventTranslator.cxx
  pqAbstractStringEventPlayer.cxx
  pqBasicWidgetEventPlayer.cxx
  pqBasicWidgetEventTranslator.cxx
Mathieu Westphal's avatar
Mathieu Westphal committed
213
  pqCheckEventOverlay.cxx
214
  pqComboBoxEventTranslator.cxx
Mathieu Westphal's avatar
Mathieu Westphal committed
215
  pqComboBoxEventPlayer.cxx
216
  pqCommentEventPlayer.cxx
217
  pqDoubleSpinBoxEventTranslator.cxx
218
  pqEventComment.cxx
219
  pqEventDispatcher.cxx
220
  pqEventObserver.cxx
221
  pqEventPlayer.cxx
Mathieu Westphal's avatar
Mathieu Westphal committed
222
  pqEventRecorder.cxx
223
  pqEventTranslator.cxx
Matthew Woehlke's avatar
Matthew Woehlke committed
224
  pqLineEditEventTranslator.cxx
225 226
  pqListViewEventPlayer.cxx
  pqListViewEventTranslator.cxx
227
  pqMenuEventTranslator.cxx
Matthew Woehlke's avatar
Matthew Woehlke committed
228 229 230
  pqNativeFileDialogEventPlayer.cxx
  pqNativeFileDialogEventTranslator.cxx
  pqObjectNaming.cxx
231
  pqPlayBackEventsDialog.cxx
Matthew Woehlke's avatar
Matthew Woehlke committed
232 233 234 235 236
  pqRecordEventsDialog.cxx
  pqSpinBoxEventTranslator.cxx
  pqStdoutEventObserver.cxx
  pqTabBarEventPlayer.cxx
  pqTabBarEventTranslator.cxx
Mathieu Westphal's avatar
Mathieu Westphal committed
237 238
  pqTableViewEventPlayer.cxx
  pqTableViewEventTranslator.cxx
Matthew Woehlke's avatar
Matthew Woehlke committed
239 240
  pqTestUtility.cxx
  pqThreadedEventSource.cxx
241
  pqTimer.cxx
Matthew Woehlke's avatar
Matthew Woehlke committed
242
  pqTreeViewEventPlayer.cxx
243
  pqTreeViewEventTranslator.cxx
Matthew Woehlke's avatar
Matthew Woehlke committed
244
  pqWidgetEventPlayer.cxx
Mathieu Westphal's avatar
Mathieu Westphal committed
245
  pqWidgetEventTranslator.cxx
Matthew Woehlke's avatar
Matthew Woehlke committed
246 247 248
)

SET(QtTesting_DEVEL_HEADERS
Mathieu Westphal's avatar
Mathieu Westphal committed
249
  QtTestingExport.h
Matthew Woehlke's avatar
Matthew Woehlke committed
250 251 252 253 254
  pq3DViewEventPlayer.h
  pq3DViewEventTranslator.h
  pqAbstractActivateEventPlayer.h
  pqAbstractBooleanEventPlayer.h
  pqAbstractButtonEventTranslator.h
Mathieu Westphal's avatar
Mathieu Westphal committed
255
  pqAbstractDoubleEventPlayer.h
Matthew Woehlke's avatar
Matthew Woehlke committed
256 257
  pqAbstractIntEventPlayer.h
  pqAbstractItemViewEventPlayer.h
Mathieu Westphal's avatar
Mathieu Westphal committed
258
  pqAbstractItemViewEventPlayerBase.h
Matthew Woehlke's avatar
Matthew Woehlke committed
259
  pqAbstractItemViewEventTranslator.h
Mathieu Westphal's avatar
Mathieu Westphal committed
260 261
  pqAbstractItemViewEventTranslatorBase.h
  pqAbstractMiscellaneousEventPlayer.h
Matthew Woehlke's avatar
Matthew Woehlke committed
262 263 264 265
  pqAbstractSliderEventTranslator.h
  pqAbstractStringEventPlayer.h
  pqBasicWidgetEventPlayer.h
  pqBasicWidgetEventTranslator.h
Mathieu Westphal's avatar
Mathieu Westphal committed
266
  pqCheckEventOverlay.h
Matthew Woehlke's avatar
Matthew Woehlke committed
267
  pqComboBoxEventTranslator.h
Mathieu Westphal's avatar
Mathieu Westphal committed
268
  pqComboBoxEventPlayer.h
269
  pqCommentEventPlayer.h
Matthew Woehlke's avatar
Matthew Woehlke committed
270
  pqDoubleSpinBoxEventTranslator.h
271
  pqEventComment.h
Matthew Woehlke's avatar
Matthew Woehlke committed
272 273 274
  pqEventDispatcher.h
  pqEventObserver.h
  pqEventPlayer.h
Mathieu Westphal's avatar
Mathieu Westphal committed
275
  pqEventRecorder.h
276
  pqEventSource.h
277
  pqEventTranslator.h
Mathieu Westphal's avatar
Mathieu Westphal committed
278
  pqEventTypes.h
279
  pqLineEditEventTranslator.h
280 281
  pqListViewEventPlayer.h
  pqListViewEventTranslator.h
282
  pqMenuEventTranslator.h
283 284
  pqNativeFileDialogEventPlayer.h
  pqNativeFileDialogEventTranslator.h
285
  pqObjectNaming.h
286
  pqPlayBackEventsDialog.h
287 288
  pqRecordEventsDialog.h
  pqSpinBoxEventTranslator.h
289
  pqStdoutEventObserver.h
290 291
  pqTabBarEventPlayer.h
  pqTabBarEventTranslator.h
Mathieu Westphal's avatar
Mathieu Westphal committed
292 293
  pqTableViewEventPlayer.h
  pqTableViewEventTranslator.h
294
  pqTestUtility.h
295
  pqThreadedEventSource.h
296
  pqTimer.h
297
  pqTreeViewEventPlayer.h
298
  pqTreeViewEventTranslator.h
299 300
  pqWidgetEventPlayer.h
  pqWidgetEventTranslator.h
Matthew Woehlke's avatar
Matthew Woehlke committed
301 302 303 304 305
  ${QtTesting_BINARY_DIR}/QtTestingConfigure.h
)

ADD_LIBRARY(QtTesting
  ${QtTesting_SOURCES}
306 307
  ${MOC_BUILT_SOURCES}
  ${UI_BUILT_SOURCES}
308
  ${QRC_BUILT_SOURCES}
309
  ${PYTHON_SRCS}
310 311
)

312 313 314 315
# Set library name to include custom prefixes/suffixes.
set_property(TARGET QtTesting
  PROPERTY OUTPUT_NAME ${QT_TESTING_CUSTOM_LIBRARY_PREFIX}QtTesting${QT_TESTING_CUSTOM_LIBRARY_SUFFIX})

316 317 318 319 320 321
SOURCE_GROUP("Generated" FILES
  ${MOC_BUILT_SOURCES}
  ${UI_BUILT_SOURCES}
)

TARGET_LINK_LIBRARIES(QtTesting
322
  ${qt_imported_targets}
323 324
)

325
IF(QT_TESTING_WITH_PYTHON)
326 327
  TARGET_LINK_LIBRARIES(QtTesting
    ${PYTHON_LIBRARIES}
328
    ${PYTHON_UTIL_LIBRARY_LIB}
329
  )
330
ENDIF()
331

332
SET(QTTESTING_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
333 334 335
CONFIGURE_FILE(${QtTesting_SOURCE_DIR}/QtTestingConfigure.h.in
               ${QtTesting_BINARY_DIR}/QtTestingConfigure.h)

336
INSTALL(TARGETS QtTesting
David Partyka's avatar
David Partyka committed
337
  EXPORT ${QT_TESTING_INSTALL_EXPORT_NAME}
338 339 340
  RUNTIME DESTINATION ${QtTesting_INSTALL_BIN_DIR} COMPONENT Runtime
  LIBRARY DESTINATION ${QtTesting_INSTALL_LIB_DIR} COMPONENT Runtime
  ARCHIVE DESTINATION ${QtTesting_INSTALL_LIB_DIR} COMPONENT Development)
341

342

343 344 345 346
option(BUILD_EXAMPLES "Build examples" OFF)
if (BUILD_EXAMPLES)
  add_subdirectory(Examples)
endif ()
347

348 349 350 351 352
include(CTest)
IF(BUILD_TESTING)
  add_subdirectory(Testing)
ENDIF()

353 354
export(TARGETS QtTesting FILE ${QtTesting_BINARY_DIR}/QtTestingExports.cmake)

355
# Set up the build export configuration
356
set(QtTesting_EXPORT_FILE "${QtTesting_BINARY_DIR}/QtTestingConfig.cmake")
357 358 359
configure_file(
  "${QtTesting_SOURCE_DIR}/QtTestingConfig.cmake.in"
  "${QtTesting_EXPORT_FILE}"
360
  @ONLY
361 362 363
)

# Set up the install export
Matthew Woehlke's avatar
Matthew Woehlke committed
364 365 366 367 368 369 370
IF(IS_ABSOLUTE QtTesting_INSTALL_INCLUDE_DIR)
  set(QtTesting_INSTALL_INCLUDE_FULL_DIR "${QtTesting_INSTALL_INCLUDE_DIR}")
ELSE()
  set(QtTesting_INSTALL_INCLUDE_FULL_DIR "${CMAKE_INSTALL_PREFIX}/${QtTesting_INSTALL_INCLUDE_DIR}")
  get_filename_component(QtTesting_INSTALL_INCLUDE_FULL_DIR "${QtTesting_INSTALL_INCLUDE_FULL_DIR}" ABSOLUTE)
ENDIF()

371 372 373 374 375 376 377
IF(IS_ABSOLUTE QtTesting_INSTALL_LIB_DIR)
  set(QtTesting_INSTALL_LIB_FULL_DIR "${QtTesting_INSTALL_LIB_DIR}")
ELSE()
  set(QtTesting_INSTALL_LIB_FULL_DIR "${CMAKE_INSTALL_PREFIX}/${QtTesting_INSTALL_LIB_DIR}")
  get_filename_component(QtTesting_INSTALL_LIB_FULL_DIR "${QtTesting_INSTALL_LIB_FULL_DIR}" ABSOLUTE)
ENDIF()

378
set(QtTesting_EXPORT_INSTALL_FILE "${QtTesting_BINARY_DIR}/CMakeFiles/QtTestingConfig.cmake")
379 380 381 382 383 384
configure_file(
  "${QtTesting_SOURCE_DIR}/QtTestingConfig-install.cmake.in"
  "${QtTesting_EXPORT_INSTALL_FILE}"
  @ONLY
)

385
IF(NOT QtTesting_INSTALL_NO_DEVELOPMENT)
Matthew Woehlke's avatar
Matthew Woehlke committed
386 387 388 389
  install( FILES ${QtTesting_DEVEL_HEADERS}
    DESTINATION ${QtTesting_INSTALL_INCLUDE_DIR}
  )

390 391 392 393
  # Configure the CMake EXPORT file during installation
  install( FILES ${QtTesting_BINARY_DIR}/CMakeFiles/QtTestingConfig.cmake
    DESTINATION ${QtTesting_INSTALL_CMAKE_DIR}
  )
394 395 396
  install( EXPORT ${QT_TESTING_INSTALL_EXPORT_NAME}
    DESTINATION ${QtTesting_INSTALL_CMAKE_DIR}
  )
397
ENDIF()