11# cmake version, project name, language
2- cmake_minimum_required (VERSION 2.8 FATAL_ERROR)
2+ cmake_minimum_required (VERSION 3.22 FATAL_ERROR)
33project (neural-fortran Fortran)
44
55# set output paths for modules, archives, and executables
@@ -19,6 +19,18 @@ else()
1919 message (STATUS "Configuring build for parallel execution" )
2020endif ()
2121
22+ find_package (HDF5 COMPONENTS Fortran HL)
23+
24+ include (FetchContent)
25+
26+ FetchContent_Declare(
27+ h5fortran
28+ GIT_REPOSITORY https://github.com/geospace-code/h5fortran
29+ GIT_TAG 3b1867bb542fae9213aded0015103b8418e53919
30+ )
31+
32+ FetchContent_MakeAvailable(h5fortran)
33+
2234# compiler flags for gfortran
2335if (CMAKE_Fortran_COMPILER_ID MATCHES GNU)
2436
@@ -101,18 +113,20 @@ add_library(neural
101113 src/nf/io/nf_io_hdf5_submodule.f90
102114)
103115
116+ target_include_directories (neural PUBLIC ${h5fortran_BUILD_DIR} /include )
117+
104118# Remove leading or trailing whitespace
105119string (REGEX REPLACE "^ | $" "" LIBS "${LIBS} " )
106120
107121# tests
108122enable_testing ()
109123foreach (execid input1d_layer input3d_layer dense_layer conv2d_layer maxpool2d_layer flatten_layer dense_network dense_network_from_keras conv2d_network io_hdf5 keras_read_model)
110124 add_executable (test_${execid} test /test_${execid} .f90)
111- target_link_libraries (test_${execid} neural ${LIBS} )
125+ target_link_libraries (test_${execid} neural h5fortran ${LIBS} )
112126 add_test (test_${execid} bin/test_${execid} )
113127endforeach ()
114128
115129foreach (execid cnn mnist mnist_from_keras simple sine)
116130 add_executable (${execid} example/${execid} .f90)
117- target_link_libraries (${execid} neural ${LIBS} )
131+ target_link_libraries (${execid} neural h5fortran ${LIBS} )
118132endforeach ()
0 commit comments