-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
481 lines (431 loc) · 16.2 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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
cmake_minimum_required(VERSION 2.8.12.2 FATAL_ERROR)
project(HDF5_VOL_TEST C)
if (POLICY CMP0074)
# find_package() uses <PackageName>_ROOT variables.
cmake_policy (SET CMP0074 NEW)
endif ()
#------------------------------------------------------------------------------
# Setup install and output Directories
#------------------------------------------------------------------------------
# Setting this ensures that "make install" will leave rpaths to external
# libraries intact on "make install". This ensures that one can install a
# version of HDF5 DAOS on the build machine without any issues. If this not
# desired, simply specify CMAKE_INSTALL_RPATH_USE_LINK_PATH when configuring
# HDF5 VOL DAOS and "make install" will strip all rpaths, which is default
# behavior.
#if(NOT CMAKE_INSTALL_RPATH_USE_LINK_PATH)
# set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
#endif()
#------------------------------------------------------------------------------
# Set module path
#------------------------------------------------------------------------------
set(HDF5_VOL_TEST_CMAKE_MODULE_PATH "${HDF5_VOL_TEST_SOURCE_DIR}/CMake")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${HDF5_VOL_TEST_CMAKE_MODULE_PATH})
#------------------------------------------------------------------------------
# Version information
#------------------------------------------------------------------------------
# TODO
#------------------------------------------------------------------------------
# Setup CMake Environment
#------------------------------------------------------------------------------
if(WIN32)
message("The HDF5 VOL test suite is currently not supported on this platform." FATAL_ERROR)
endif()
#------------------------------------------------------------------------------
if(NOT HDF5_VOL_TEST_EXTERNALLY_CONFIGURED)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all Executables."
)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all Libraries"
)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all static libraries."
)
endif()
#------------------------------------------------------------------------------
# Disallow in-source build
#------------------------------------------------------------------------------
if("${HDF5_VOL_TEST_SOURCE_DIR}" STREQUAL "${HDF5_VOL_TEST_BINARY_DIR}")
message(FATAL_ERROR
"The HDF5 VOL test suite requires an out of source Build. "
"Please create a separate binary directory and run CMake there.")
endif()
#------------------------------------------------------------------------------
# Set a default build type if none was specified
#------------------------------------------------------------------------------
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()
if(NOT CMAKE_C_FLAGS AND CMAKE_COMPILER_IS_GNUCC)
message(STATUS "GCC detected, setting additional flags")
set(CMAKE_C_FLAGS "-Wall -Wextra -Winline -Wcast-qual -std=gnu99 -Wshadow" CACHE STRING "Flags used by the compiler during all build types." FORCE)
endif()
#-----------------------------------------------------------------------------
# Testing
#-----------------------------------------------------------------------------
if(NOT HDF5_VOL_TEST_EXTERNALLY_CONFIGURED)
enable_testing()
include(CTest)
endif()
#------------------------------------------------------------------------------
# Include source and build directories
#------------------------------------------------------------------------------
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
#------------------------------------------------------------------------------
# External dependencies
#------------------------------------------------------------------------------
# HDF5
if (POLICY CMP0074)
SET(HDF5_ROOT ${HDF5_DIR})
endif ()
# Save a copy of HDF5_DIR set by the user.
SET(ORIG_HDF5_DIR ${HDF5_DIR})
find_package(HDF5 NO_MODULE NAMES hdf5 COMPONENTS C shared)
if(HDF5_FOUND)
set(HDF5_C_SHARED_LIBRARY hdf5-shared)
if(NOT TARGET ${HDF5_C_SHARED_LIBRARY})
message(FATAL_ERROR "Could not find hdf5 shared target, please make "
"sure that HDF5 has been compiled with shared libraries enabled.")
endif()
set(HDF5_VOL_TEST_EXT_PKG_DEPENDENCIES
${HDF5_VOL_TEST_EXT_PKG_DEPENDENCIES}
${HDF5_C_SHARED_LIBRARY}
)
else()
if ("${ORIG_HDF5_DIR}" STREQUAL "")
message(FATAL_ERROR "Setting HDF5_DIR is required")
endif()
# If above find_package failed, then HDF5_DIR will be set to
# "HDF5_DIR-NOTFOUND". Thus, We must restore HDF5_DIR to the original
# HDF5_DIR set by user.
SET(HDF5_DIR ${ORIG_HDF5_DIR})
# Allow for HDF5 autotools builds. Note FindHDF5 module requires h5cc or h5pcc.
find_package(HDF5 MODULE)
if ("${HDF5_DIR}" STREQUAL "HDF5_DIR-NOTFOUND")
# FindHDF5 module fails to find h5cc or h5pcc under $PATH
SET(HDF5_DIR ${ORIG_HDF5_DIR})
find_path(HDF5_INCLUDE_DIRS NAMES hdf5.h PATHS ${HDF5_DIR}/include)
find_library(HDF5_LIBRARIES hdf5 PATHS ${HDF5_DIR}/lib)
endif()
if ("${HDF5_INCLUDE_DIRS}" STREQUAL "HDF5_INCLUDE_DIRS-NOTFOUND")
message(FATAL_ERROR "HDF5 header file 'hdf5.h' could not be found")
endif()
if ("${HDF5_LIBRARIES}" STREQUAL "HDF5_LIBRARIES-NOTFOUND")
message(FATAL_ERROR "HDF5 library file 'libhdf5.a' could not be found")
endif()
set(HDF5_VOL_TEST_EXT_INCLUDE_DEPENDENCIES
${HDF5_VOL_TEST_EXT_INCLUDE_DEPENDENCIES}
${HDF5_INCLUDE_DIRS}
)
set(HDF5_VOL_TEST_EXT_LIB_DEPENDENCIES
${HDF5_VOL_TEST_EXT_LIB_DEPENDENCIES}
${HDF5_LIBRARIES}
)
endif()
# HDF5 tests in separate tests
option(HDF5_VOL_TEST_ENABLE_PART
"Enable testing in separate tests." OFF)
# HDF5 async tests
option(HDF5_VOL_TEST_ENABLE_ASYNC
"Enable async API tests." OFF)
if(HDF5_VOL_TEST_ENABLE_ASYNC)
set(H5VL_TEST_HAS_ASYNC 1)
endif()
# Parallel HDF5 tests
option(HDF5_VOL_TEST_ENABLE_PARALLEL
"Enable testing in parallel (requires MPI)." OFF)
if(HDF5_VOL_TEST_ENABLE_PARALLEL)
set(H5VL_TEST_HAS_PARALLEL 1)
endif()
if(HDF5_VOL_TEST_ENABLE_PARALLEL OR HDF5_ENABLE_PARALLEL)
# MPI
find_package(MPI REQUIRED)
set(HDF5_VOL_TEST_EXT_INCLUDE_DEPENDENCIES
${HDF5_VOL_TEST_EXT_INCLUDE_DEPENDENCIES}
${MPI_INCLUDE_PATH}
)
set(HDF5_VOL_TEST_EXT_LIB_DEPENDENCIES
${HDF5_VOL_TEST_EXT_LIB_DEPENDENCIES}
${MPI_LIBRARIES}
)
endif()
#set(HDF5_VOL_TEST_INIT_COMMAND "" CACHE STRING
# "Command to run before a test begins. Multiple commands are separated by ';'.")
#mark_as_advanced(HDF5_VOL_TEST_INIT_COMMAND)
#------------------------------------------------------------------------------
# Compile kwsys library and setup TestDriver
#------------------------------------------------------------------------------
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/h5vl_test_config.h.in
${CMAKE_CURRENT_BINARY_DIR}/h5vl_test_config.h
)
add_subdirectory(driver)
#-----------------------------------------------------------------------------
# Define Sources and tests
#-----------------------------------------------------------------------------
# Generic VOL tests
set(vol_tests
attribute
dataset
datatype
file
group
link
misc
object
)
if(HDF5_VOL_TEST_ENABLE_ASYNC)
set(vol_tests
${vol_tests}
async
)
endif()
# Ported HDF5 tests
set(hdf5_tests
testhdf5
)
if(HDF5_VOL_TEST_ENABLE_PARALLEL)
set(hdf5_partests
t_bigio
t_pshutdown
t_shapesame
testphdf5
)
endif()
foreach(vol_test ${vol_tests})
set(HDF5_VOL_TEST_SRCS
${HDF5_VOL_TEST_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/vol_${vol_test}_test.c
)
if(HDF5_VOL_TEST_ENABLE_PARALLEL)
set(HDF5_VOL_TEST_PARALLEL_SRCS
${HDF5_VOL_TEST_PARALLEL_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/vol_${vol_test}_test_parallel.c
)
endif()
endforeach()
add_executable(h5vl_test ${HDF5_VOL_TEST_SRCS} vol_test.c vol_test_util.c)
if(HDF5_VOL_TEST_ENABLE_PARALLEL)
add_executable(h5vl_test_parallel
${HDF5_VOL_TEST_PARALLEL_SRCS} vol_test_parallel.c vol_test_util.c)
endif()
# target_include_directories(h5vl_test
# PUBLIC "$<BUILD_INTERFACE:${HDF5_VOL_TEST_BUILD_INCLUDE_DEPENDENCIES}>"
# )
target_include_directories(h5vl_test
SYSTEM PUBLIC ${HDF5_VOL_TEST_EXT_INCLUDE_DEPENDENCIES}
)
if(HDF5_VOL_TEST_ENABLE_PARALLEL)
target_include_directories(h5vl_test_parallel
SYSTEM PUBLIC ${HDF5_VOL_TEST_EXT_INCLUDE_DEPENDENCIES}
)
endif()
target_link_libraries(h5vl_test
${HDF5_VOL_TEST_EXPORTED_LIBS}
${HDF5_VOL_TEST_EXT_LIB_DEPENDENCIES}
${HDF5_VOL_TEST_EXT_PKG_DEPENDENCIES}
)
if(HDF5_VOL_TEST_ENABLE_PARALLEL)
target_link_libraries(h5vl_test_parallel
${HDF5_VOL_TEST_EXPORTED_LIBS}
${HDF5_VOL_TEST_EXT_LIB_DEPENDENCIES}
${HDF5_VOL_TEST_EXT_PKG_DEPENDENCIES}
)
endif()
# Include the ported HDF5 tests
# Serial tests
foreach(hdf5_test ${hdf5_tests})
if(${hdf5_test} STREQUAL "testhdf5")
add_executable(h5_test_${hdf5_test}
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/${hdf5_test}.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/tarray.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/tattr.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/tchecksum.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/tconfig.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/tcoords.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/tfile.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/tgenprop.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/th5o.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/th5s.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/tid.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/titerate.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/tmisc.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/trefer.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/tselect.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/ttime.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/tunicode.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/tvlstr.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/tvltypes.c
)
else()
add_executable(h5_test_${hdf5_test} ${CMAKE_CURRENT_SOURCE_DIR}/hdf5_test/${hdf5_test}.c)
endif()
target_include_directories(h5_test_${hdf5_test}
SYSTEM PUBLIC ${HDF5_VOL_TEST_EXT_INCLUDE_DEPENDENCIES}
)
target_link_libraries(h5_test_${hdf5_test}
${HDF5_VOL_TEST_EXPORTED_LIBS}
${HDF5_VOL_TEST_EXT_LIB_DEPENDENCIES}
${HDF5_VOL_TEST_EXT_PKG_DEPENDENCIES}
)
endforeach()
# Parallel tests
if(HDF5_VOL_TEST_ENABLE_PARALLEL)
foreach(hdf5_partest ${hdf5_partests})
if(${hdf5_partest} STREQUAL "testphdf5")
add_executable(h5_partest_${hdf5_partest}
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_testpar/${hdf5_partest}.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_testpar/t_ph5basic.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_testpar/t_file.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_testpar/t_dset.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_testpar/t_mdset.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_testpar/t_coll_chunk.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_testpar/t_span_tree.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_testpar/t_prop.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_testpar/t_file_image.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_testpar/t_coll_md_read.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_testpar/t_chunk_alloc.c
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_testpar/t_filter_read.c
)
else()
add_executable(h5_partest_${hdf5_partest}
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_testpar/${hdf5_partest}.c)
endif()
target_include_directories(h5_partest_${hdf5_partest}
SYSTEM PUBLIC ${HDF5_VOL_TEST_EXT_INCLUDE_DEPENDENCIES}
)
target_link_libraries(h5_partest_${hdf5_partest}
${HDF5_VOL_TEST_EXPORTED_LIBS}
${HDF5_VOL_TEST_EXT_LIB_DEPENDENCIES}
${HDF5_VOL_TEST_EXT_PKG_DEPENDENCIES}
)
endforeach()
endif()
#------------------------------------------------------------------------------
# Tests
#------------------------------------------------------------------------------
if(HDF5_VOL_TEST_SERVER)
# Driver options
if(HDF5_VOL_TEST_SERVER_ALLOW_ERRORS)
set(HDF5_VOL_TEST_DRIVER_EXTRA_FLAGS --allow-server-errors)
endif()
if(HDF5_VOL_TEST_CLIENT_HELPER)
set(HDF5_VOL_TEST_DRIVER_EXTRA_FLAGS ${HDF5_VOL_TEST_DRIVER_EXTRA_FLAGS}
--client-helper ${HDF5_VOL_TEST_CLIENT_HELPER})
endif()
if(HDF5_VOL_TEST_CLIENT_INIT)
set(HDF5_VOL_TEST_DRIVER_EXTRA_FLAGS ${HDF5_VOL_TEST_DRIVER_EXTRA_FLAGS}
--client-init ${HDF5_VOL_TEST_CLIENT_INIT})
endif()
# Serial dynamic client/server test
if(NOT HDF5_VOL_TEST_ENABLE_PART)
add_test(NAME "h5vl_test"
COMMAND $<TARGET_FILE:h5vl_test_driver>
--server ${HDF5_VOL_TEST_SERVER}
--client $<TARGET_FILE:h5vl_test>
--serial
${HDF5_VOL_TEST_DRIVER_EXTRA_FLAGS}
)
else()
set(last_vol_test "")
foreach(vol_test ${vol_tests})
add_test(NAME "h5vl_test_${vol_test}"
COMMAND $<TARGET_FILE:h5vl_test_driver>
--server ${HDF5_VOL_TEST_SERVER}
--client $<TARGET_FILE:h5vl_test> ${vol_test}
--serial
${HDF5_VOL_TEST_DRIVER_EXTRA_FLAGS}
)
set_tests_properties("h5vl_test_${vol_test}" PROPERTIES DEPENDS "${last_vol_test}")
set(last_vol_test "h5vl_test_${vol_test}")
endforeach()
endif()
foreach(hdf5_test ${hdf5_tests})
add_test(NAME "h5_test_${hdf5_test}"
COMMAND $<TARGET_FILE:h5vl_test_driver>
--server ${HDF5_VOL_TEST_SERVER}
--client $<TARGET_FILE:h5_test_${hdf5_test}>
--serial
${HDF5_VOL_TEST_DRIVER_EXTRA_FLAGS}
)
endforeach()
# Hook external tests to same test suite
foreach(ext_vol_test ${HDF5_VOL_EXT_SERIAL_TESTS})
add_test(NAME "h5vl_ext_${ext_vol_test}"
COMMAND $<TARGET_FILE:h5vl_test_driver>
--server ${HDF5_VOL_TEST_SERVER}
--client $<TARGET_FILE:${ext_vol_test}>
--serial
${HDF5_VOL_TEST_DRIVER_EXTRA_FLAGS}
)
endforeach()
# Parallel dynamic client/server test
if(HDF5_VOL_TEST_ENABLE_PARALLEL)
add_test(NAME "h5vl_test_parallel"
COMMAND $<TARGET_FILE:h5vl_test_driver>
--server ${HDF5_VOL_TEST_SERVER}
--client $<TARGET_FILE:h5vl_test_parallel>
${HDF5_VOL_TEST_DRIVER_EXTRA_FLAGS}
)
foreach(hdf5_partest ${hdf5_partests})
add_test(NAME "h5_partest_${hdf5_partest}"
COMMAND $<TARGET_FILE:h5vl_test_driver>
--server ${HDF5_VOL_TEST_SERVER}
--client $<TARGET_FILE:h5_partest_${hdf5_partest}>
${HDF5_VOL_TEST_DRIVER_EXTRA_FLAGS}
)
endforeach()
# Hook external tests to same test suite
foreach(ext_vol_test ${HDF5_VOL_EXT_PARALLEL_TESTS})
add_test(NAME "h5vl_ext_${ext_vol_test}"
COMMAND $<TARGET_FILE:h5vl_test_driver>
--server ${HDF5_VOL_TEST_SERVER}
--client $<TARGET_FILE:${ext_vol_test}>
${HDF5_VOL_TEST_DRIVER_EXTRA_FLAGS}
)
endforeach()
endif()
else()
if(NOT HDF5_VOL_TEST_ENABLE_PART)
add_test(NAME "h5vl_test"
COMMAND $<TARGET_FILE:h5vl_test>
)
else()
set(last_vol_test "")
foreach(vol_test ${vol_tests})
add_test(NAME "h5vl_test_${vol_test}"
COMMAND $<TARGET_FILE:h5vl_test> ${vol_test}
)
set_tests_properties("h5vl_test_${vol_test}" PROPERTIES DEPENDS "${last_vol_test}")
set(last_vol_test "h5vl_test_${vol_test}")
endforeach()
endif()
foreach(hdf5_test ${hdf5_tests})
add_test(NAME "h5_test_${hdf5_test}"
COMMAND $<TARGET_FILE:h5_test_${hdf5_test}>
)
endforeach()
if(HDF5_VOL_TEST_ENABLE_PARALLEL)
add_test(NAME "h5vl_test_parallel"
COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS}
${MPIEXEC_PREFLAGS} $<TARGET_FILE:h5vl_test_parallel>
${MPIEXEC_POSTFLAGS}
)
foreach(hdf5_partest ${hdf5_partests})
add_test(NAME "h5_partest_${hdf5_partest}"
COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS}
${MPIEXEC_PREFLAGS} $<TARGET_FILE:h5_partest_${hdf5_partest}>
${MPIEXEC_POSTFLAGS}
)
endforeach()
endif()
endif()