Skip to content

Commit 69e2dbe

Browse files
committed
First attempt including h5fortran in CMake build
1 parent 69237b3 commit 69e2dbe

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

CMakeLists.txt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# cmake version, project name, language
2-
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
2+
cmake_minimum_required(VERSION 3.22 FATAL_ERROR)
33
project(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")
2020
endif()
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
2335
if(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
105119
string(REGEX REPLACE "^ | $" "" LIBS "${LIBS}")
106120

107121
# tests
108122
enable_testing()
109123
foreach(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})
113127
endforeach()
114128

115129
foreach(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})
118132
endforeach()

0 commit comments

Comments
 (0)