Skip to content

Commit 58a8072

Browse files
committed
add option h5fortran_IGNORE_CONDA_LIBRARIES
add option h5fortran_python for testing fixes #48
1 parent 8ef7704 commit 58a8072

File tree

8 files changed

+48
-38
lines changed

8 files changed

+48
-38
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ env:
44
HOMEBREW_NO_INSTALL_CLEANUP: 1
55
CTEST_NO_TESTS_ACTION: error
66
CTEST_PARALLEL_LEVEL: 0
7-
CMAKE_BUILD_PARALLEL_LEVEL: 4
87
CMAKE_INSTALL_PREFIX: ~/libs
98
CMAKE_PREFIX_PATH: ~/libs
109

.github/workflows/composite-pkg/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ runs:
88

99
- uses: actions/setup-python@v5
1010
with:
11-
python-version: '3.12'
11+
python-version: '3.13'
1212

1313
- name: Python pkgs
1414
shell: bash

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ endif()
2525
# --- avoid Anaconda libraries
2626
find_package(Python COMPONENTS Interpreter)
2727

28-
if(DEFINED ENV{CONDA_PREFIX})
28+
if(DEFINED ENV{CONDA_PREFIX} AND h5fortran_IGNORE_CONDA_LIBRARIES)
2929
list(APPEND CMAKE_IGNORE_PREFIX_PATH $ENV{CONDA_PREFIX})
3030
list(APPEND CMAKE_IGNORE_PATH $ENV{CONDA_PREFIX}/bin)
3131
# need CMAKE_IGNORE_PATH for CMake < 3.23

CMakePresets.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
"name": "default",
77
"binaryDir": "${sourceDir}/build",
88
"cacheVariables": {
9-
"CMAKE_COMPILE_WARNING_AS_ERROR": true
9+
"CMAKE_COMPILE_WARNING_AS_ERROR": true,
10+
"h5fortran_BUILD_TESTING": true,
11+
"h5fortran_find": true,
12+
"h5fortran_python": true
1013
}
1114
},
1215
{
@@ -29,7 +32,7 @@
2932
"description": "Build with code coverage enabled.",
3033
"cacheVariables": {
3134
"CMAKE_BUILD_TYPE": "Debug",
32-
"h5fortran_COVERAGE": true
35+
"h5fortran_coverage": true
3336
}
3437
}
3538
],

cmake/CheckHDF5.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ endmacro()
1919

2020
function(hdf5_run_err_diag stderr)
2121

22-
if(DEFINED ENV{CONDA_PREFIX})
22+
if(DEFINED ENV{CONDA_PREFIX} AND h5fortran_IGNORE_CONDA_LIBRARIES)
2323
message(WARNING "suggest running 'conda deactivate' and re-running cmake as Conda may be interfering with HDF5 library.")
2424
elseif(WIN32 AND stderr MATCHES "0xc0000135")
2525
message(STATUS "test run error may be due to missing HDF5 DLLs in PATH

cmake/compilers.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ add_compile_options(
5555
endif()
5656

5757
# --- code coverage
58-
if(h5fortran_COVERAGE)
58+
if(h5fortran_coverage)
5959
include(${CMAKE_CURRENT_LIST_DIR}/Modules/CodeCoverage.cmake)
6060
append_coverage_compiler_flags()
6161
set(COVERAGE_EXCLUDES ${PROJECT_SOURCE_DIR}/test)
6262
endif()
6363

6464
# --- clang-tidy
65-
if(tidy AND h5fortran_IS_TOP_LEVEL)
65+
if(h5fortran_tidy AND h5fortran_IS_TOP_LEVEL)
6666
find_program(CLANG_TIDY_EXE NAMES "clang-tidy" REQUIRED)
6767
set(CMAKE_C_CLANG_TIDY ${CLANG_TIDY_EXE})
6868
set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_EXE})

options.cmake

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ message(STATUS "${PROJECT_NAME} ${PROJECT_VERSION} CMake ${CMAKE_VERSION} Toolch
22

33
include(GNUInstallDirs)
44

5-
option(h5fortran_find "try to find libraries" on)
5+
option(h5fortran_find "try to find HDF5 library" ON)
66

7-
option(h5fortran_COVERAGE "Code coverage tests")
8-
option(tidy "Run clang-tidy on the code")
7+
option(h5fortran_coverage "Code coverage tests")
8+
option(h5fortran_tidy "Run clang-tidy on the code")
99

10-
option(matlab "check HDF5 file writes with Matlab")
11-
option(concepts "conceptual testing, for devs only" off)
10+
option(h5fortran_matlab "check HDF5 file writes with Matlab")
11+
option(h5fortran_python "check HDF5 file writes with Python")
12+
13+
option(h5fortran_IGNORE_CONDA_LIBRARIES "If ON, CMake will not search for the
14+
hdf5 libraries in a Conda environment." ON)
1215

1316
option(h5fortran_BUILD_TESTING "build tests" ${h5fortran_IS_TOP_LEVEL})
1417

test/CMakeLists.txt

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ set(attr_file ${CMAKE_CURRENT_BINARY_DIR}/test_attr_py.h5)
1515
set(shape_file ${CMAKE_CURRENT_BINARY_DIR}/test_shape.h5)
1616
set(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

2034
add_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
6175
cast 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
6377
fail_read_size_mismatch fail_read_rank_mismatch fail_nonexist_variable)
6478
if(HAVE_IEEE_ARITH)
6579
list(APPEND test_names fill)
6680
endif()
81+
if(h5py_ok)
82+
list(APPEND test_names attributes_read string_read)
83+
endif()
6784

6885
setup_test("${test_names}")
6986

@@ -85,7 +102,7 @@ REQUIRED_FILES ${CMAKE_CURRENT_BINARY_DIR}/deflate1.h5
85102
LABELS deflate
86103
)
87104

88-
if(h5fortran_COVERAGE)
105+
if(h5fortran_coverage)
89106
setup_target_for_coverage_gcovr_html(
90107
NAME coverage
91108
EXECUTABLE ${CMAKE_CTEST_COMMAND}
@@ -99,27 +116,15 @@ if(WIN32 AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.22)
99116
)
100117
endif()
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

116123
set_property(TEST string_read PROPERTY FIXTURES_REQUIRED h5str)
117124
set_property(TEST string_read PROPERTY REQUIRED_FILES ${string_file})
118125

119-
# --- attributes
120-
121126
add_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

125130
set_property(TEST PythonAttributes PROPERTY FIXTURES_SETUP h5attr)
@@ -130,26 +135,26 @@ set_property(TEST attributes_read PROPERTY REQUIRED_FILES ${attr_file})
130135
# --- shape
131136

132137
add_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

136141
set_property(TEST PythonShape PROPERTY REQUIRED_FILES ${shape_file})
137142
set_property(TEST PythonShape PROPERTY FIXTURES_REQUIRED h5shape)
138143

139144
# --- String
140145
add_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

144149
set_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-
148151
set_property(TEST PythonAttributes PythonShape PythonString PROPERTY LABELS python)
149152

153+
endif()
154+
150155
# --- Matlab HDF5
151156

152-
if(matlab)
157+
if(h5fortran_matlab)
153158
find_package(Matlab COMPONENTS MAIN_PROGRAM REQUIRED)
154159

155160
set(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}
163168
FIXTURES_REQUIRED h5shape
164169
)
165170

166-
endif(matlab)
171+
endif()
167172

168173
# --- h5ls
169174

0 commit comments

Comments
 (0)