Skip to content

Commit 3704445

Browse files
committed
add find_hdf5 option (default true)
1 parent ece7815 commit 3704445

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

CMakeLists.txt

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
cmake_minimum_required(VERSION 3.19...3.28)
22

3+
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
4+
message(FATAL_ERROR "please use out-of-source build
5+
cmake -Bbuild")
6+
endif()
7+
38
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
49
if(NOT is_multi_config AND NOT (CMAKE_BUILD_TYPE OR DEFINED ENV{CMAKE_BUILD_TYPE}))
510
set(CMAKE_BUILD_TYPE Release CACHE STRING "Release default")
611
endif()
712

813
project(h5fortran
914
LANGUAGES C Fortran
10-
VERSION 2.0.2
15+
VERSION 2.1.0
1116
)
1217

1318
include(CTest)
@@ -43,23 +48,29 @@ if(hdf5_parallel)
4348
include(cmake/check_mpi.cmake)
4449
check_mpi_version()
4550

46-
find_package(HDF5 COMPONENTS Fortran parallel)
51+
if(find_hdf5)
52+
find_package(HDF5 COMPONENTS Fortran parallel)
53+
endif()
4754

4855
if(HDF5_FOUND)
56+
if(HDF5_VERSION VERSION_LESS 1.10.2)
57+
message(WARNING "HDF5 >= 1.10.2 is needed for HDF5-MPI")
58+
endif()
4959
include(cmake/hdf5_compression.cmake)
5060
hdf5_compression_flag()
5161
else()
5262
include(cmake/hdf5.cmake)
5363
endif()
5464
else()
55-
find_package(HDF5 COMPONENTS Fortran)
65+
if(find_hdf5)
66+
find_package(HDF5 COMPONENTS Fortran)
67+
endif()
68+
if(NOT HDF5_FOUND)
69+
include(cmake/hdf5.cmake)
70+
endif()
5671
set(hdf5_parallel_compression ".false.")
5772
endif()
5873

59-
if(HDF5_VERSION VERSION_LESS 1.10.2)
60-
message(WARNING "HDF5 >= 1.10.2 is needed for HDF5-MPI")
61-
endif()
62-
6374
# --- h5fortran library
6475

6576
configure_file(src/hdf5_config.f90.in hdf5_config.f90 @ONLY)

options.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
include(GNUInstallDirs)
2-
31
message(STATUS "${PROJECT_NAME} ${PROJECT_VERSION} CMake ${CMAKE_VERSION}")
42

3+
option(find_hdf5 "search for HDF5 and Zlib" true)
4+
55
option(benchmark "Run benchmarks")
66
option(coverage "Code coverage tests")
77
option(tidy "Run clang-tidy on the code")
@@ -16,6 +16,7 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND ${PROJECT_NAME}_IS_TOP_LEVEL)
1616
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/local" CACHE PATH "install prefix" FORCE)
1717
endif()
1818

19+
set_property(DIRECTORY PROPERTY EP_UPDATE_DISCONNECTED true)
1920

2021
if(BUILD_SHARED_LIBS AND MSVC)
2122
message(WARNING "Intel oneAPI has trouble with shared libs in general on Windows, try

scripts/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ LANGUAGES C Fortran
66
)
77

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

1110
# --- system checks
1211
file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX})

0 commit comments

Comments
 (0)