-
Notifications
You must be signed in to change notification settings - Fork 14
/
CMakeLists.txt
351 lines (309 loc) · 10 KB
/
CMakeLists.txt
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
PROJECT(QtTesting)
IF(NOT DEFINED QtTesting_QT_VERSION)
SET(QtTesting_QT_VERSION "5" CACHE STRING "Expected Qt version")
MARK_AS_ADVANCED(QtTesting_QT_VERSION)
SET_PROPERTY(CACHE QtTesting_QT_VERSION PROPERTY STRINGS 5 6)
ENDIF()
IF(NOT (QtTesting_QT_VERSION VERSION_EQUAL "5" OR
QtTesting_QT_VERSION VERSION_EQUAL "6"))
message(FATAL_ERROR "Expected value for QtTesting_QT_VERSION is either '5' or '6'")
ENDIF()
set(qt_imported_targets)
FIND_PACKAGE(Qt${QtTesting_QT_VERSION} REQUIRED COMPONENTS Core Widgets Gui)
SET(qt_imported_targets Qt${QtTesting_QT_VERSION}::Core Qt${QtTesting_QT_VERSION}::Widgets Qt${QtTesting_QT_VERSION}::Gui)
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()
IF(NOT DEFINED QtTesting_INSTALL_INCLUDE_DIR)
SET(QtTesting_INSTALL_INCLUDE_DIR include/QtTesting)
ENDIF()
IF(NOT DEFINED QtTesting_INSTALL_LIB_DIR)
SET(QtTesting_INSTALL_LIB_DIR lib)
ENDIF()
IF(NOT DEFINED QtTesting_INSTALL_CMAKE_DIR)
SET(QtTesting_INSTALL_CMAKE_DIR lib/cmake/qttesting)
ENDIF()
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()
IF(NOT DEFINED QT_TESTING_INSTALL_EXPORT_NAME)
SET(QT_TESTING_INSTALL_EXPORT_NAME QtTestingTargets)
ENDIF()
# 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()
IF(QT_TESTING_WITH_PYTHON)
IF(NOT PythonLibs_FOUND)
FIND_PACKAGE(PythonLibs REQUIRED)
ENDIF()
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})
ENDIF()
ENDIF()
INCLUDE_DIRECTORIES(
${PYTHON_INCLUDE_PATH}
)
SET(PYTHON_SRCS
pqPythonEventObserver.cxx
pqPythonEventObserver.h
pqPythonEventSource.cxx
pqPythonEventSource.h
)
ENDIF(QT_TESTING_WITH_PYTHON)
set(ui_files
pqPlayBackEventsDialog.ui
pqRecordEventsDialog.ui)
set(rc_files
Resources/QtTesting.qrc)
set(CMAKE_AUTOMOC 1)
set(CMAKE_AUTOUIC 1)
set(CMAKE_AUTORCC 1)
SET(QtTesting_SOURCES
pq3DViewEventPlayer.cxx
pq3DViewEventTranslator.cxx
pqAbstractActivateEventPlayer.cxx
pqAbstractBooleanEventPlayer.cxx
pqAbstractButtonEventTranslator.cxx
pqAbstractDoubleEventPlayer.cxx
pqAbstractIntEventPlayer.cxx
pqAbstractItemViewEventPlayer.cxx
pqAbstractItemViewEventPlayerBase.cxx
pqAbstractItemViewEventTranslator.cxx
pqAbstractItemViewEventTranslatorBase.cxx
pqAbstractMiscellaneousEventPlayer.cxx
pqAbstractSliderEventTranslator.cxx
pqAbstractStringEventPlayer.cxx
pqBasicWidgetEventPlayer.cxx
pqBasicWidgetEventTranslator.cxx
pqCheckEventOverlay.cxx
pqComboBoxEventTranslator.cxx
pqComboBoxEventPlayer.cxx
pqCommentEventPlayer.cxx
pqDoubleSpinBoxEventTranslator.cxx
pqEventComment.cxx
pqEventDispatcher.cxx
pqEventObserver.cxx
pqEventPlayer.cxx
pqEventRecorder.cxx
pqEventTranslator.cxx
pqLineEditEventTranslator.cxx
pqListViewEventPlayer.cxx
pqListViewEventTranslator.cxx
pqMenuEventTranslator.cxx
pqNativeFileDialogEventPlayer.cxx
pqNativeFileDialogEventTranslator.cxx
pqObjectNaming.cxx
pqPlayBackEventsDialog.cxx
pqRecordEventsDialog.cxx
pqSpinBoxEventTranslator.cxx
pqStdoutEventObserver.cxx
pqTabBarEventPlayer.cxx
pqTabBarEventTranslator.cxx
pqTableViewEventPlayer.cxx
pqTableViewEventTranslator.cxx
pqTestUtility.cxx
pqThreadedEventSource.cxx
pqTimer.cxx
pqTreeViewEventPlayer.cxx
pqTreeViewEventTranslator.cxx
pqWidgetEventPlayer.cxx
pqWidgetEventTranslator.cxx
)
SET(QtTesting_DEVEL_HEADERS
QtTestingExport.h
pq3DViewEventPlayer.h
pq3DViewEventTranslator.h
pqAbstractActivateEventPlayer.h
pqAbstractBooleanEventPlayer.h
pqAbstractButtonEventTranslator.h
pqAbstractDoubleEventPlayer.h
pqAbstractIntEventPlayer.h
pqAbstractItemViewEventPlayer.h
pqAbstractItemViewEventPlayerBase.h
pqAbstractItemViewEventTranslator.h
pqAbstractItemViewEventTranslatorBase.h
pqAbstractMiscellaneousEventPlayer.h
pqAbstractSliderEventTranslator.h
pqAbstractStringEventPlayer.h
pqBasicWidgetEventPlayer.h
pqBasicWidgetEventTranslator.h
pqCheckEventOverlay.h
pqComboBoxEventTranslator.h
pqComboBoxEventPlayer.h
pqCommentEventPlayer.h
pqDoubleSpinBoxEventTranslator.h
pqEventComment.h
pqEventDispatcher.h
pqEventObserver.h
pqEventPlayer.h
pqEventRecorder.h
pqEventSource.h
pqEventTranslator.h
pqEventTypes.h
pqLineEditEventTranslator.h
pqListViewEventPlayer.h
pqListViewEventTranslator.h
pqMenuEventTranslator.h
pqNativeFileDialogEventPlayer.h
pqNativeFileDialogEventTranslator.h
pqObjectNaming.h
pqPlayBackEventsDialog.h
pqRecordEventsDialog.h
pqSpinBoxEventTranslator.h
pqStdoutEventObserver.h
pqTabBarEventPlayer.h
pqTabBarEventTranslator.h
pqTableViewEventPlayer.h
pqTableViewEventTranslator.h
pqTestUtility.h
pqThreadedEventSource.h
pqTimer.h
pqTreeViewEventPlayer.h
pqTreeViewEventTranslator.h
pqWidgetEventPlayer.h
pqWidgetEventTranslator.h
${QtTesting_BINARY_DIR}/QtTestingConfigure.h
)
if(NOT DEFINED QTTESTING_BUILD_AS_VTK_MODULE)
option(QTTESTING_BUILD_AS_VTK_MODULE "Build QtTesting as a VTK module" OFF)
ENDIF()
if (QTTESTING_BUILD_AS_VTK_MODULE)
# When building as a ThirdParty in ParaView
# or in any vtk module based software
# it can be useful to build qttesting as a VTK Module.
# This macro is defined in VTK cmake macros
vtk_module_add_module(ParaView::qttesting
SOURCES
${QtTesting_SOURCES}
${ui_files}
${rc_files}
${PYTHON_SRCS}
HEADERS
${QtTesting_DEVEL_HEADERS}
HEADERS_SUBDIR
"vtkqttesting"
)
set_target_properties(qttesting
PROPERTIES
DEFINE_SYMBOL QtTesting_EXPORTS)
add_library(ParaView::qttesting ALIAS qttesting)
target_include_directories(qttesting
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
"$<INSTALL_INTERFACE:${_vtk_build_HEADERS_DESTINATION}/vtkqttesting>")
else ()
add_library(qttesting
${QtTesting_SOURCES}
${ui_files}
${rc_files}
${PYTHON_SRCS}
${QtTesting_DEVEL_HEADERS})
add_library(QtTesting ALIAS qttesting)
target_include_directories(
qttesting
PUBLIC
$<INSTALL_INTERFACE:${QtTesting_INSTALL_INCLUDE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")
endif ()
target_compile_definitions(qttesting PRIVATE QT_NO_KEYWORDS)
# 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})
TARGET_LINK_LIBRARIES(qttesting PRIVATE
${qt_imported_targets}
)
IF(QT_TESTING_WITH_PYTHON)
TARGET_LINK_LIBRARIES(qttesting
VTK::Python
)
ENDIF()
SET(QTTESTING_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
CONFIGURE_FILE(${QtTesting_SOURCE_DIR}/QtTestingConfigure.h.in
${QtTesting_BINARY_DIR}/QtTestingConfigure.h)
if (NOT QTTESTING_BUILD_AS_VTK_MODULE)
INSTALL(TARGETS qttesting
EXPORT ${QT_TESTING_INSTALL_EXPORT_NAME}
RUNTIME DESTINATION ${QtTesting_INSTALL_BIN_DIR} COMPONENT Runtime
LIBRARY DESTINATION ${QtTesting_INSTALL_LIB_DIR} COMPONENT Runtime
ARCHIVE DESTINATION ${QtTesting_INSTALL_LIB_DIR} COMPONENT Development)
endif ()
if (NOT DEFINED BUILD_EXAMPLES)
option(BUILD_EXAMPLES "Build examples" OFF)
endif ()
if (BUILD_EXAMPLES)
add_subdirectory(Examples)
endif ()
include(CTest)
IF(BUILD_TESTING)
add_subdirectory(Testing)
ENDIF()
export(TARGETS qttesting FILE ${QtTesting_BINARY_DIR}/QtTestingExports.cmake)
# Set up the build export configuration
set(QtTesting_EXPORT_FILE "${QtTesting_BINARY_DIR}/QtTestingConfig.cmake")
configure_file(
"${QtTesting_SOURCE_DIR}/QtTestingConfig.cmake.in"
"${QtTesting_EXPORT_FILE}"
@ONLY
)
# Set up the install export
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()
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()
set(QtTesting_EXPORT_INSTALL_FILE "${QtTesting_BINARY_DIR}/CMakeFiles/QtTestingConfig.cmake")
configure_file(
"${QtTesting_SOURCE_DIR}/QtTestingConfig-install.cmake.in"
"${QtTesting_EXPORT_INSTALL_FILE}"
@ONLY
)
include(CMakePackageConfigHelpers)
# Configure '<PROJECT-NAME>Config.cmake'
# Use variables:
# * targets_export_name
# * PROJECT_NAME
configure_package_config_file(
"${PROJECT_NAME}Config-install.cmake.in"
"${QtTesting_EXPORT_INSTALL_FILE}"
INSTALL_DESTINATION "${QtTesting_INSTALL_CMAKE_DIR}"
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
IF(NOT QtTesting_INSTALL_NO_DEVELOPMENT)
install( FILES ${QtTesting_DEVEL_HEADERS}
DESTINATION ${QtTesting_INSTALL_INCLUDE_DIR}
)
# Configure the CMake EXPORT file during installation
install( FILES ${QtTesting_BINARY_DIR}/CMakeFiles/QtTestingConfig.cmake
DESTINATION ${QtTesting_INSTALL_CMAKE_DIR}
)
install( EXPORT ${QT_TESTING_INSTALL_EXPORT_NAME}
DESTINATION ${QtTesting_INSTALL_CMAKE_DIR}
)
ENDIF()