@@ -15,6 +15,20 @@ set(attr_file ${CMAKE_CURRENT_BINARY_DIR}/test_attr_py.h5)
1515set (shape_file ${CMAKE_CURRENT_BINARY_DIR} /test_shape.h5)
1616set (string_file ${CMAKE_CURRENT_BINARY_DIR} /test_string_py.h5)
1717
18+ # --- Python h5py
19+ if (NOT DEFINED h5py_ok AND Python_EXECUTABLE)
20+ execute_process (COMMAND ${Python_EXECUTABLE} -c "import h5py"
21+ RESULT_VARIABLE ret
22+ ERROR_VARIABLE err
23+ )
24+ message (VERBOSE "${ret} ${err} " )
25+ if (ret EQUAL 0)
26+ set (h5py_ok true CACHE BOOL "h5py OK" )
27+ else ()
28+ set (h5py_ok false CACHE BOOL "h5py not OK" )
29+ endif ()
30+ endif ()
31+
1832# --- fundamental HDF5 library check
1933
2034add_executable (test_minimal test_minimal.f90)
@@ -57,13 +71,16 @@ endfunction(setup_test)
5771
5872# --- setup unit tests
5973
60- set (test_names array attributes attributes_read
74+ set (test_names array attributes
6175cast deflate_write deflate_read deflate_props destructor exist
62- groups layout lt scalar shape string string_read version write
76+ groups layout lt scalar shape string version write
6377fail_read_size_mismatch fail_read_rank_mismatch fail_nonexist_variable)
6478if (HAVE_IEEE_ARITH)
6579 list (APPEND test_names fill)
6680endif ()
81+ if (h5py_ok)
82+ list (APPEND test_names attributes_read string_read)
83+ endif ()
6784
6885setup_test("${test_names} " )
6986
@@ -85,7 +102,7 @@ REQUIRED_FILES ${CMAKE_CURRENT_BINARY_DIR}/deflate1.h5
85102LABELS deflate
86103)
87104
88- if (h5fortran_COVERAGE )
105+ if (h5fortran_coverage )
89106setup_target_for_coverage_gcovr_html(
90107NAME coverage
91108EXECUTABLE ${CMAKE_CTEST_COMMAND}
@@ -99,27 +116,15 @@ if(WIN32 AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.22)
99116 )
100117endif ()
101118
102- # --- Python h5py
103- if (NOT DEFINED h5py_ok)
104- execute_process (COMMAND ${Python_EXECUTABLE} -c "import h5py"
105- RESULT_VARIABLE ret
106- ERROR_VARIABLE err
107- )
108- message (VERBOSE "${ret} ${err} " )
109- if (ret EQUAL 0)
110- set (h5py_ok true CACHE BOOL "h5py OK" )
111- else ()
112- set (h5py_ok false CACHE BOOL "h5py not OK" )
113- endif ()
114- endif ()
119+ # --- attributes
120+
121+ if (h5py_ok)
115122
116123set_property (TEST string_read PROPERTY FIXTURES_REQUIRED h5str)
117124set_property (TEST string_read PROPERTY REQUIRED_FILES ${string_file} )
118125
119- # --- attributes
120-
121126add_test (NAME PythonAttributes
122- COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR} /generate_attributes.py ${attr_file}
127+ COMMAND Python::Interpreter ${CMAKE_CURRENT_SOURCE_DIR} /generate_attributes.py ${attr_file}
123128)
124129
125130set_property (TEST PythonAttributes PROPERTY FIXTURES_SETUP h5attr)
@@ -130,26 +135,26 @@ set_property(TEST attributes_read PROPERTY REQUIRED_FILES ${attr_file})
130135# --- shape
131136
132137add_test (NAME PythonShape
133- COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR} /check_shape.py ${shape_file}
138+ COMMAND Python::Interpreter ${CMAKE_CURRENT_SOURCE_DIR} /check_shape.py ${shape_file}
134139)
135140
136141set_property (TEST PythonShape PROPERTY REQUIRED_FILES ${shape_file} )
137142set_property (TEST PythonShape PROPERTY FIXTURES_REQUIRED h5shape)
138143
139144# --- String
140145add_test (NAME PythonString
141- COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR} /generate_string_data.py ${string_file}
146+ COMMAND Python::Interpreter ${CMAKE_CURRENT_SOURCE_DIR} /generate_string_data.py ${string_file}
142147)
143148
144149set_property (TEST PythonString PROPERTY FIXTURES_SETUP h5str)
145150
146- set_property (TEST string_read PythonAttributes PythonShape PythonString attributes_read PROPERTY DISABLED $<NOT :$<BOOL :${h5py_ok} >>)
147-
148151set_property (TEST PythonAttributes PythonShape PythonString PROPERTY LABELS python)
149152
153+ endif ()
154+
150155# --- Matlab HDF5
151156
152- if (matlab )
157+ if (h5fortran_matlab )
153158find_package (Matlab COMPONENTS MAIN_PROGRAM REQUIRED)
154159
155160set (matlab_cmd "i=h5info('${shape_file} ', '/d7').Dataspace.Size; assert(all(i == [2, 1, 3, 4, 7, 6, 5]))" )
@@ -163,7 +168,7 @@ REQUIRED_FILES ${shape_file}
163168FIXTURES_REQUIRED h5shape
164169)
165170
166- endif (matlab )
171+ endif ()
167172
168173# --- h5ls
169174
0 commit comments