Skip to content

Commit

Permalink
add find_hdf5 option (default true)
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Dec 11, 2023
1 parent ece7815 commit ef8b938
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
32 changes: 26 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,43 @@ if(hdf5_parallel)
include(cmake/check_mpi.cmake)
check_mpi_version()

find_package(HDF5 COMPONENTS Fortran parallel)
if(find_hdf5)
find_package(HDF5 COMPONENTS Fortran parallel)
endif()

if(HDF5_FOUND)
if(HDF5_VERSION VERSION_LESS 1.10.2)
message(WARNING "HDF5 >= 1.10.2 is needed for HDF5-MPI")
endif()
include(cmake/hdf5_compression.cmake)
hdf5_compression_flag()
else()
# HDF5 install fails to work (link) if prior HDF5 library is installed there
find_package(HDF5 CONFIG PATHS ${CMAKE_INSTALL_PREFIX} NO_DEFAULT_PATH QUIET)
if(HDF5_FOUND)
message(FATAL_ERROR "HDF5 library already installed: ${HDF5_DIR}
Please pick a new install location or completely remove the old HDF5 install directory.
Otherwise, HDF5 will fail to link correctly with prior version and this version mixed.")
endif()
include(cmake/hdf5.cmake)
endif()
else()
find_package(HDF5 COMPONENTS Fortran)
if(find_hdf5)
find_package(HDF5 COMPONENTS Fortran)
endif()
if(NOT HDF5_FOUND)
# HDF5 install fails to work (link) if prior HDF5 library is installed there
find_package(HDF5 CONFIG PATHS ${CMAKE_INSTALL_PREFIX} NO_DEFAULT_PATH QUIET)
if(HDF5_FOUND)
message(FATAL_ERROR "HDF5 library already installed: ${HDF5_DIR}
Please pick a new install location or completely remove the old HDF5 install directory.
Otherwise, HDF5 will fail to link correctly with prior version and this version mixed.")
endif()
include(cmake/hdf5.cmake)
endif()
set(hdf5_parallel_compression ".false.")
endif()

if(HDF5_VERSION VERSION_LESS 1.10.2)
message(WARNING "HDF5 >= 1.10.2 is needed for HDF5-MPI")
endif()

# --- h5fortran library

configure_file(src/hdf5_config.f90.in hdf5_config.f90 @ONLY)
Expand Down
5 changes: 3 additions & 2 deletions options.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include(GNUInstallDirs)

message(STATUS "${PROJECT_NAME} ${PROJECT_VERSION} CMake ${CMAKE_VERSION}")

option(find_hdf5 "search for HDF5 and Zlib" true)

option(benchmark "Run benchmarks")
option(coverage "Code coverage tests")
option(tidy "Run clang-tidy on the code")
Expand All @@ -16,6 +16,7 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND ${PROJECT_NAME}_IS_TOP_LEVEL)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/local" CACHE PATH "install prefix" FORCE)
endif()

set_property(DIRECTORY PROPERTY EP_UPDATE_DISCONNECTED true)

if(BUILD_SHARED_LIBS AND MSVC)
message(WARNING "Intel oneAPI has trouble with shared libs in general on Windows, try
Expand Down
1 change: 0 additions & 1 deletion scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ LANGUAGES C Fortran
)

option(hdf5_parallel "build HDF5 parallel MPI" on)
option(zlib_legacy "use legacy zlib 1.x")

# --- system checks
file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX})
Expand Down

0 comments on commit ef8b938

Please sign in to comment.