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 3704445
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
25 changes: 18 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
cmake_minimum_required(VERSION 3.19...3.28)

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "please use out-of-source build
cmake -Bbuild")
endif()

get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT is_multi_config AND NOT (CMAKE_BUILD_TYPE OR DEFINED ENV{CMAKE_BUILD_TYPE}))
set(CMAKE_BUILD_TYPE Release CACHE STRING "Release default")
endif()

project(h5fortran
LANGUAGES C Fortran
VERSION 2.0.2
VERSION 2.1.0
)

include(CTest)
Expand Down Expand Up @@ -43,23 +48,29 @@ 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()
include(cmake/hdf5.cmake)
endif()
else()
find_package(HDF5 COMPONENTS Fortran)
if(find_hdf5)
find_package(HDF5 COMPONENTS Fortran)
endif()
if(NOT HDF5_FOUND)
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 3704445

Please sign in to comment.