mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-24 16:04:40 +08:00
Merge pull request #2 from ZedThree/cmake-hdf5-tidy-2
Cmake hdf5 tidy 2
This commit is contained in:
commit
8ae2260f6e
6
.github/workflows/run_tests_cdash.yml
vendored
6
.github/workflows/run_tests_cdash.yml
vendored
@ -18,7 +18,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hdf5: [ 1.10.8, 1.12.2, 1.14.0 ]
|
||||
hdf5: [ 1.10.8, 1.12.2, 1.14.3 ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@ -66,7 +66,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hdf5: [ 1.14.0 ]
|
||||
hdf5: [ 1.14.3 ]
|
||||
|
||||
steps:
|
||||
|
||||
@ -126,7 +126,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hdf5: [ 1.10.8, 1.12.2, 1.14.0 ]
|
||||
hdf5: [ 1.10.8, 1.12.2, 1.14.3 ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
10
.github/workflows/run_tests_osx.yml
vendored
10
.github/workflows/run_tests_osx.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hdf5: [ 1.12.2, 1.14.0 ]
|
||||
hdf5: [ 1.12.2, 1.14.3 ]
|
||||
|
||||
steps:
|
||||
|
||||
@ -57,7 +57,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hdf5: [ 1.12.2, 1.14.0 ]
|
||||
hdf5: [ 1.12.2, 1.14.3 ]
|
||||
use_nc4: [ nc3, nc4 ]
|
||||
use_dap: [ dap_off, dap_on ]
|
||||
use_nczarr: [ nczarr_off, nczarr_on ]
|
||||
@ -163,7 +163,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hdf5: [ 1.12.2, 1.14.0 ]
|
||||
hdf5: [ 1.12.2, 1.14.3 ]
|
||||
use_nc4: [ nc3, nc4 ]
|
||||
use_dap: [ dap_off, dap_on ]
|
||||
use_nczarr: [ nczarr_off, nczarr_on ]
|
||||
@ -259,7 +259,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hdf5: [ 1.12.2, 1.14.0 ]
|
||||
hdf5: [ 1.12.2, 1.14.3 ]
|
||||
steps:
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
@ -340,7 +340,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hdf5: [ 1.12.2, 1.14.0 ]
|
||||
hdf5: [ 1.12.2, 1.14.3 ]
|
||||
|
||||
steps:
|
||||
|
||||
|
4
.github/workflows/run_tests_s3.yml
vendored
4
.github/workflows/run_tests_s3.yml
vendored
@ -23,7 +23,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hdf5: [ 1.10.8, 1.12.2, 1.14.0 ]
|
||||
hdf5: [ 1.10.8, 1.12.2, 1.14.3 ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@ -70,7 +70,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hdf5: [ 1.14.0 ]
|
||||
hdf5: [ 1.14.3 ]
|
||||
steps:
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
|
16
.github/workflows/run_tests_ubuntu.yml
vendored
16
.github/workflows/run_tests_ubuntu.yml
vendored
@ -18,7 +18,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hdf5: [ 1.10.8, 1.12.2, 1.14.0 ]
|
||||
hdf5: [ 1.10.8, 1.12.2, 1.14.3 ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@ -66,7 +66,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hdf5: [ 1.14.0 ]
|
||||
hdf5: [ 1.14.3 ]
|
||||
|
||||
steps:
|
||||
|
||||
@ -128,7 +128,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hdf5: [ 1.14.0 ]
|
||||
hdf5: [ 1.14.3 ]
|
||||
steps:
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
@ -223,7 +223,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hdf5: [ 1.14.0 ]
|
||||
hdf5: [ 1.14.3 ]
|
||||
steps:
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
@ -303,7 +303,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hdf5: [ 1.14.0 ]
|
||||
hdf5: [ 1.14.3 ]
|
||||
|
||||
steps:
|
||||
|
||||
@ -383,7 +383,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hdf5: [ 1.14.0 ]
|
||||
hdf5: [ 1.14.3 ]
|
||||
|
||||
steps:
|
||||
|
||||
@ -460,7 +460,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hdf5: [1.10.8, 1.12.2, 1.14.0 ]
|
||||
hdf5: [1.10.8, 1.12.2, 1.14.3 ]
|
||||
use_nc4: [ nc3, nc4 ]
|
||||
use_dap: [ dap_off, dap_on ]
|
||||
use_nczarr: [ nczarr_off, nczarr_on ]
|
||||
@ -624,7 +624,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hdf5: [ 1.10.8, 1.12.2, 1.14.0 ]
|
||||
hdf5: [ 1.10.8, 1.12.2, 1.14.3 ]
|
||||
use_nc4: [ nc3, nc4 ]
|
||||
use_dap: [ dap_off, dap_on ]
|
||||
use_nczarr: [ nczarr_off, nczarr_on ]
|
||||
|
@ -109,223 +109,39 @@ if(USE_HDF5)
|
||||
##
|
||||
set(HDF5_VERSION_REQUIRED 1.8.10)
|
||||
|
||||
|
||||
###
|
||||
# For now we assume that if we are building netcdf
|
||||
# as a shared library, we will use hdf5 as a shared
|
||||
# library. If we are building netcdf statically,
|
||||
# we will use a static library. This can be toggled
|
||||
# by explicitly modifying NC_FIND_SHARED_LIBS.
|
||||
##
|
||||
# Accommodate developers who have hdf5 libraries and
|
||||
# headers on their system, but do not have a the hdf
|
||||
# .cmake files. If this is the case, they should
|
||||
# specify HDF5_HL_LIBRARY, HDF5_LIBRARY, HDF5_INCLUDE_DIR manually.
|
||||
#
|
||||
# This script will attempt to determine the version of the HDF5 library programatically.
|
||||
##
|
||||
if(HDF5_C_LIBRARY AND HDF5_HL_LIBRARY AND HDF5_INCLUDE_DIR)
|
||||
set(HDF5_LIBRARIES ${HDF5_C_LIBRARY} ${HDF5_HL_LIBRARY} )
|
||||
set(HDF5_C_LIBRARIES ${HDF5_C_LIBRARY} )
|
||||
set(HDF5_C_LIBRARY_hdf5 ${HDF5_C_LIBRARY} )
|
||||
set(HDF5_HL_LIBRARIES ${HDF5_HL_LIBRARY} )
|
||||
target_include_directories(netcdf
|
||||
PRIVATE
|
||||
${HDF5_INCLUDE_DIR}
|
||||
)
|
||||
message(STATUS "Using HDF5 C Library: ${HDF5_C_LIBRARY}")
|
||||
message(STATUS "Using HDF5 HL LIbrary: ${HDF5_HL_LIBRARY}")
|
||||
if (EXISTS "${HDF5_INCLUDE_DIR}/H5pubconf.h")
|
||||
file(READ "${HDF5_INCLUDE_DIR}/H5pubconf.h" _hdf5_version_lines
|
||||
REGEX "#define[ \t]+H5_VERSION")
|
||||
string(REGEX REPLACE ".*H5_VERSION .*\"\(.*\)\".*" "\\1" _hdf5_version "${_hdf5_version_lines}")
|
||||
set(HDF5_VERSION "${_hdf5_version}" CACHE STRING "")
|
||||
set(HDF5_VERSION ${HDF5_VERSION} PARENT_SCOPE)
|
||||
unset(_hdf5_version)
|
||||
unset(_hdf5_version_lines)
|
||||
endif ()
|
||||
message(STATUS "Found HDF5 libraries version ${HDF5_VERSION}")
|
||||
###
|
||||
# If HDF5_VERSION is still empty, we have a problem.
|
||||
# Error out.
|
||||
###
|
||||
if("${HDF5_VERSION}" STREQUAL "")
|
||||
message(FATAL_ERR "Unable to determine HDF5 version. NetCDF requires at least version ${HDF5_VERSION_REQUIRED}. Please ensure that libhdf5 is installed and accessible.")
|
||||
endif()
|
||||
if(NC_FIND_SHARED_LIBS)
|
||||
set(HDF5_USE_STATIC_LIBRARIES OFF)
|
||||
else(NC_FIND_SHARED_LIBS)
|
||||
set(HDF5_USE_STATIC_LIBRARIES ON)
|
||||
endif(NC_FIND_SHARED_LIBS)
|
||||
|
||||
###
|
||||
# Now that we know HDF5_VERSION isn't empty, we can check for minimum required version,
|
||||
# and toggle various options.
|
||||
###
|
||||
if(${HDF5_VERSION} VERSION_LESS ${HDF5_VERSION_REQUIRED})
|
||||
message(FATAL_ERROR "netCDF requires at least HDF5 ${HDF5_VERSION_REQUIRED}. Found ${HDF5_VERSION}.")
|
||||
endif()
|
||||
#####
|
||||
# First, find the C and HL libraries.
|
||||
#####
|
||||
find_package(HDF5 ${HDF5_VERSION_REQUIRED} COMPONENTS C HL REQUIRED)
|
||||
|
||||
else(HDF5_C_LIBRARY AND HDF5_HL_LIBRARY AND HDF5_INCLUDE_DIR) # We are seeking out HDF5 with Find Package.
|
||||
###
|
||||
# For now we assume that if we are building netcdf
|
||||
# as a shared library, we will use hdf5 as a shared
|
||||
# library. If we are building netcdf statically,
|
||||
# we will use a static library. This can be toggled
|
||||
# by explicitly modifying NC_FIND_SHARED_LIBS.
|
||||
##
|
||||
if(NC_FIND_SHARED_LIBS)
|
||||
set(NC_HDF5_LINK_TYPE "shared")
|
||||
set(NC_HDF5_LINK_TYPE_UPPER "SHARED")
|
||||
ADD_DEFINITIONS(-DH5_BUILT_AS_DYNAMIC_LIB)
|
||||
else(NC_FIND_SHARED_LIBS)
|
||||
set(NC_HDF5_LINK_TYPE "static")
|
||||
set(NC_HDF5_LINK_TYPE_UPPER "STATIC")
|
||||
ADD_DEFINITIONS(-DH5_BUILT_AS_STATIC_LIB )
|
||||
endif(NC_FIND_SHARED_LIBS)
|
||||
|
||||
#####
|
||||
# First, find the C and HL libraries.
|
||||
#
|
||||
# This has been updated to reflect what is in the hdf5
|
||||
# examples, even though the previous version of what we
|
||||
# had worked.
|
||||
#####
|
||||
if(MSVC)
|
||||
set(SEARCH_PACKAGE_NAME ${HDF5_PACKAGE_NAME})
|
||||
find_package(HDF5 NAMES ${SEARCH_PACKAGE_NAME} COMPONENTS C HL CONFIG REQUIRED ${NC_HDF5_LINK_TYPE})
|
||||
else(MSVC)
|
||||
find_package(HDF5 COMPONENTS C HL REQUIRED)
|
||||
endif(MSVC)
|
||||
|
||||
##
|
||||
# Next, check the HDF5 version. This will inform which
|
||||
# HDF5 variables we need to munge.
|
||||
##
|
||||
|
||||
# Some versions of HDF5 set HDF5_VERSION_STRING instead of HDF5_VERSION
|
||||
if(HDF5_VERSION_STRING AND NOT HDF5_VERSION)
|
||||
set(HDF5_VERSION ${HDF5_VERSION_STRING})
|
||||
endif()
|
||||
|
||||
|
||||
###
|
||||
# If HDF5_VERSION is undefined, attempt to determine it programatically.
|
||||
###
|
||||
if("${HDF5_VERSION}" STREQUAL "")
|
||||
message(STATUS "HDF5_VERSION not detected. Attempting to determine programatically.")
|
||||
IF (EXISTS "${HDF5_INCLUDE_DIR}/H5pubconf.h")
|
||||
file(READ "${HDF5_INCLUDE_DIR}/H5pubconf.h" _hdf5_version_lines
|
||||
REGEX "#define[ \t]+H5_VERSION")
|
||||
string(REGEX REPLACE ".*H5_VERSION .*\"\(.*\)\".*" "\\1" _hdf5_version "${_hdf5_version_lines}")
|
||||
set(HDF5_VERSION "${_hdf5_version}" CACHE STRING "")
|
||||
unset(_hdf5_version)
|
||||
unset(_hdf5_version_lines)
|
||||
message(STATUS "Found HDF5 libraries version ${HDF5_VERSION}")
|
||||
endif()
|
||||
else()
|
||||
set(HDF5_VERSION ${HDF5_VERSION} CACHE STRING "")
|
||||
endif()
|
||||
|
||||
###
|
||||
# If HDF5_VERSION is still empty, we have a problem.
|
||||
# Error out.
|
||||
###
|
||||
if("${HDF5_VERSION}" STREQUAL "")
|
||||
message(FATAL_ERR "Unable to determine HDF5 version. NetCDF requires at least version ${HDF5_VERSION_REQUIRED}. Please ensure that libhdf5 is installed and accessible.")
|
||||
endif()
|
||||
|
||||
###
|
||||
# Now that we know HDF5_VERSION isn't empty, we can check for minimum required version,
|
||||
# and toggle various options.
|
||||
###
|
||||
|
||||
if(${HDF5_VERSION} VERSION_LESS ${HDF5_VERSION_REQUIRED})
|
||||
message(FATAL_ERROR "netCDF requires at least HDF5 ${HDF5_VERSION_REQUIRED}. Found ${HDF5_VERSION}.")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
##
|
||||
# Include the HDF5 include directory.
|
||||
##
|
||||
if(HDF5_INCLUDE_DIRS AND NOT HDF5_INCLUDE_DIR)
|
||||
set(HDF5_INCLUDE_DIR ${HDF5_INCLUDE_DIRS} )
|
||||
endif()
|
||||
message(STATUS "Using HDF5 include dir: ${HDF5_INCLUDE_DIR}")
|
||||
target_include_directories(netcdf
|
||||
PRIVATE
|
||||
${HDF5_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
###
|
||||
# This is the block where we figure out what the appropriate
|
||||
# variables are, and we ensure that we end up with
|
||||
# HDF5_C_LIBRARY, HDF5_HL_LIBRARY and HDF5_LIBRARIES.
|
||||
###
|
||||
if(MSVC)
|
||||
####
|
||||
# Environmental variables in Windows when using MSVC
|
||||
# are a hot mess between versions.
|
||||
####
|
||||
|
||||
##
|
||||
# HDF5 1.8.15 defined HDF5_LIBRARIES.
|
||||
##
|
||||
if(${HDF5_VERSION} VERSION_LESS "1.8.16")
|
||||
set(HDF5_C_LIBRARY hdf5 )
|
||||
set(HDF5_C_LIBRARY_hdf5 hdf5 )
|
||||
endif(${HDF5_VERSION} VERSION_LESS "1.8.16")
|
||||
|
||||
if(${HDF5_VERSION} VERSION_GREATER "1.8.15")
|
||||
if(NOT HDF5_LIBRARIES AND HDF5_C_${NC_HDF5_LINK_TYPE_UPPER}_LIBRARY AND HDF5_HL_${NC_HDF5_LINK_TYPE_UPPER}_LIBRARY)
|
||||
set(HDF5_C_LIBRARY ${HDF5_C_${NC_HDF5_LINK_TYPE_UPPER}_LIBRARY} )
|
||||
set(HDF5_C_LIBRARY_hdf5 ${HDF5_C_${NC_HDF5_LINK_TYPE_UPPER}_LIBRARY} )
|
||||
set(HDF5_HL_LIBRARY ${HDF5_HL_${NC_HDF5_LINK_TYPE_UPPER}_LIBRARY} )
|
||||
|
||||
set(HDF5_LIBRARIES ${HDF5_C_${NC_HDF5_LINK_TYPE_UPPER}_LIBRARY} ${HDF5_HL_${NC_HDF5_LINK_TYPE_UPPER}_LIBRARY} )
|
||||
endif()
|
||||
endif(${HDF5_VERSION} VERSION_GREATER "1.8.15")
|
||||
|
||||
else(MSVC)
|
||||
|
||||
# Depending on the install, either HDF5_hdf_library or
|
||||
# HDF5_C_LIBRARIES may be defined. We must check for either.
|
||||
if(HDF5_C_LIBRARIES AND NOT HDF5_hdf5_LIBRARY)
|
||||
set(HDF5_hdf5_LIBRARY ${HDF5_C_LIBRARIES} )
|
||||
endif()
|
||||
|
||||
# Some versions of find_package set HDF5_C_LIBRARIES, but not HDF5_C_LIBRARY
|
||||
# We use HDF5_C_LIBRARY below, so need to make sure it is set.
|
||||
if(HDF5_C_LIBRARIES AND NOT HDF5_C_LIBRARY)
|
||||
set(HDF5_C_LIBRARY ${HDF5_C_LIBRARIES} )
|
||||
endif()
|
||||
|
||||
# Same issue as above...
|
||||
if(HDF5_HL_LIBRARIES AND NOT HDF5_HL_LIBRARY)
|
||||
set(HDF5_HL_LIBRARY ${HDF5_HL_LIBRARIES} )
|
||||
endif()
|
||||
|
||||
endif(MSVC)
|
||||
if(NOT HDF5_C_LIBRARY)
|
||||
set(HDF5_C_LIBRARY hdf5 )
|
||||
endif()
|
||||
|
||||
endif(HDF5_C_LIBRARY AND HDF5_HL_LIBRARY AND HDF5_INCLUDE_DIR)
|
||||
message(STATUS "Using HDF5 include dir: ${HDF5_INCLUDE_DIRS}")
|
||||
target_link_libraries(netcdf
|
||||
PRIVATE
|
||||
HDF5::HDF5
|
||||
)
|
||||
|
||||
find_package(Threads)
|
||||
|
||||
# There is a missing case in the above code so default it
|
||||
if(NOT HDF5_C_LIBRARY_hdf5 OR "${HDF5_C_LIBRARY_hdf5}" STREQUAL "" )
|
||||
set(HDF5_C_LIBRARY_hdf5 "${HDF5_C_LIBRARY}" )
|
||||
endif()
|
||||
|
||||
find_path(HAVE_HDF5_H hdf5.h PATHS ${HDF5_INCLUDE_DIR} NO_DEFAULT_PATH)
|
||||
if(NOT HAVE_HDF5_H)
|
||||
message(FATAL_ERROR "Compiling a test with hdf5 failed. Either hdf5.h cannot be found, or the log messages should be checked for another reason.")
|
||||
else(NOT HAVE_HDF5_H)
|
||||
target_include_directories(netcdf
|
||||
PRIVATE
|
||||
${HAVE_HDF5_H}
|
||||
)
|
||||
endif(NOT HAVE_HDF5_H)
|
||||
|
||||
include(cmake/check_hdf5.cmake)
|
||||
set (CMAKE_REQUIRED_INCLUDES ${HDF5_INCLUDE_DIRS})
|
||||
|
||||
# Check to ensure that HDF5 was built with zlib.
|
||||
# This needs to be near the beginning since we
|
||||
# need to know whether to add "-lz" to the symbol
|
||||
# tests below.
|
||||
|
||||
include(check_hdf5)
|
||||
check_hdf5_feature(HAVE_HDF5_ZLIB H5_HAVE_ZLIB_H)
|
||||
if(NOT HAVE_HDF5_ZLIB)
|
||||
message(FATAL_ERROR "HDF5 was built without zlib. Rebuild HDF5 with zlib.")
|
||||
@ -358,38 +174,22 @@ if(USE_HDF5)
|
||||
set(HDF5_UTF8_PATHS OFF )
|
||||
endif()
|
||||
|
||||
message("-- HDF5_UTF8_PATHS (HDF5 version 1.10.6+): ${HDF5_UTF8_PATHS}")
|
||||
message(STATUS "-- HDF5_UTF8_PATHS (HDF5 version 1.10.6+): ${HDF5_UTF8_PATHS}")
|
||||
|
||||
# Find out if HDF5 was built with parallel support.
|
||||
# Do that by checking for the targets H5Pget_fapl_mpiposx and
|
||||
# H5Pget_fapl_mpio in ${HDF5_LIB}.
|
||||
set(HDF5_PARALLEL ${HDF5_IS_PARALLEL})
|
||||
|
||||
# H5Pset_fapl_mpiposix and H5Pget_fapl_mpiposix have been removed since HDF5 1.8.12.
|
||||
# Use H5Pset_fapl_mpio and H5Pget_fapl_mpio, instead.
|
||||
# CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Pget_fapl_mpiposix "" HDF5_IS_PARALLEL_MPIPOSIX)
|
||||
|
||||
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Pget_fapl_mpio "" HDF5_IS_PARALLEL_MPIO)
|
||||
if(HDF5_IS_PARALLEL_MPIO)
|
||||
set(HDF5_PARALLEL ON)
|
||||
else()
|
||||
set(HDF5_PARALLEL OFF)
|
||||
endif()
|
||||
set(HDF5_PARALLEL ${HDF5_PARALLEL} )
|
||||
set(CMAKE_REQUIRED_LIBRARIES HDF5::HDF5)
|
||||
include(CheckSymbolExists)
|
||||
|
||||
#Check to see if HDF5 library has collective metadata APIs, (HDF5 >= 1.10.0)
|
||||
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Pset_all_coll_metadata_ops "" HDF5_HAS_COLL_METADATA_OPS)
|
||||
|
||||
if(HDF5_PARALLEL)
|
||||
set(HDF5_CC h5pcc )
|
||||
else()
|
||||
set(HDF5_CC h5cc )
|
||||
endif()
|
||||
check_symbol_exists(H5Pset_all_coll_metadata_ops "hdf5.h" HDF5_HAS_COLL_METADATA_OPS)
|
||||
|
||||
# Check to see if H5Dread_chunk is available
|
||||
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Dread_chunk "" HAS_READCHUNKS)
|
||||
check_symbol_exists(H5Dread_chunk "hdf5.h" HAS_READCHUNKS)
|
||||
|
||||
# Check to see if H5Pset_fapl_ros3 is available
|
||||
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Pset_fapl_ros3 "" HAS_HDF5_ROS3)
|
||||
check_symbol_exists(H5Pset_fapl_ros3 "hdf5.h" HAS_HDF5_ROS3)
|
||||
|
||||
# Check to see if this is hdf5-1.10.3 or later.
|
||||
if(HAS_READCHUNKS)
|
||||
@ -409,23 +209,6 @@ if(USE_HDF5)
|
||||
set(HDF5_HAS_PAR_FILTERS FALSE CACHE BOOL "" )
|
||||
set(HAS_PAR_FILTERS no CACHE STRING "" )
|
||||
endif()
|
||||
|
||||
find_path(HAVE_HDF5_H hdf5.h PATHS ${HDF5_INCLUDE_DIR} NO_DEFAULT_PATH)
|
||||
if(NOT HAVE_HDF5_H)
|
||||
message(FATAL_ERROR "Compiling a test with hdf5 failed. Either hdf5.h cannot be found, or the log messages should be checked for another reason.")
|
||||
else(NOT HAVE_HDF5_H)
|
||||
target_include_directories(netcdf
|
||||
PRIVATE
|
||||
${HAVE_HDF5_H}
|
||||
)
|
||||
endif(NOT HAVE_HDF5_H)
|
||||
|
||||
#option to include HDF5 High Level header file (hdf5_hl.h) in case we are not doing a make install
|
||||
target_include_directories(netcdf
|
||||
PRIVATE
|
||||
${HDF5_HL_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
endif(USE_HDF5)
|
||||
|
||||
################################
|
||||
|
@ -283,12 +283,6 @@ are set when opening a binary file on Windows. */
|
||||
/* Define to 1 if you have libsz */
|
||||
#cmakedefine HAVE_SZ 1
|
||||
|
||||
/* Define to 1 if you have the <hdf5.h> header file. */
|
||||
#cmakedefine HAVE_HDF5_H 1
|
||||
|
||||
/* Define to 1 if you have the <hdf5.h> header file. */
|
||||
#cmakedefine HAVE_HDF5_HL_H 1
|
||||
|
||||
/* Define to 1 if the system has the type `int64'. */
|
||||
#cmakedefine HAVE_INT64 1
|
||||
|
||||
|
24
docs/FAQ.md
24
docs/FAQ.md
@ -1944,23 +1944,12 @@ Not at this time; it is required to instead build first one version, and then th
|
||||
How can I specify linking against a particular library? {#partlib}
|
||||
-------------------------------------------------------
|
||||
|
||||
It depends on the library. To specify a custom `ZLib`, for example, you would do the following:
|
||||
|
||||
$ cmake [Source Directory] -DZLIB_LIBRARY=/path/to/my/zlib.lib
|
||||
|
||||
|
||||
`HDF5` is more complex, since it requires both the `hdf5` and `hdf5_hl` libraries. You would specify custom `HDF5` libraries as follows:
|
||||
|
||||
$ cmake [Source Directory] -DHDF5_C_LIBRARY=/path/to/hdf5.lib \
|
||||
-DHDF5_HL_LIBRARY=/path/to/hdf5_hl.lib \
|
||||
-DHDF5_INCLUDE_DIR=/path/to/hdf5/include
|
||||
|
||||
|
||||
Alternatively, you may specify:
|
||||
For most libraries, you can specify `<library name>_ROOT`. To specify
|
||||
custom `ZLib` and `HDF5`, for example, you would do the following:
|
||||
|
||||
$ cmake [Source Directory] \
|
||||
-DHDF5_LIBRARIES="/path/to/hdf5.lib;/path/to/hdf5_hl.lib" \
|
||||
-DHDF5_INCLUDE_DIRS=/path/to/hdf5/include/
|
||||
-DZLIB_ROOT=/path/to/zlib/install \
|
||||
-DHDF5_ROOT=/path/to/hdf5/install
|
||||
|
||||
|
||||
What if I want to link against multiple libraries in a non-standard location {#nonstdloc}
|
||||
@ -1982,11 +1971,8 @@ How can I specify a Parallel Build using HDF5 {#parallelhdf}
|
||||
|
||||
If cmake is having problems finding the parallel `HDF5` install, you can specify the location manually:
|
||||
|
||||
|
||||
$ cmake [Source Directory] -DENABLE_PARALLEL=ON \
|
||||
-DHDF5_C_LIBRARY=/usr/lib64/openmpi/lib/libhdf5.so \
|
||||
-DHDF5_HL_LIBRARY=/usr/lib64/openmpi/lib/libhdf5.hl.so \
|
||||
-DHDF5_INCLUDE_DIR=/usr/include/openmpi-x86_64 \
|
||||
-DHDF5_ROOT=/usr/lib64/openmpi/lib/
|
||||
|
||||
You will, of course, need to use the location of the libraries specific to your development environment.
|
||||
|
||||
|
@ -14,8 +14,7 @@ FOREACH(CTEST ${H5TESTS})
|
||||
ADD_EXECUTABLE(${CTEST} ${CTEST}.c)
|
||||
TARGET_LINK_LIBRARIES(${CTEST}
|
||||
netcdf
|
||||
${HDF5_HL_LIBRARIES}
|
||||
${HDF5_C_LIBRARIES}
|
||||
HDF5::HDF5 hdf5::hdf5_hl
|
||||
)
|
||||
ADD_TEST(${CTEST} ${EXECUTABLE_OUTPUT_PATH}/${CTEST})
|
||||
ENDFOREACH()
|
||||
|
@ -69,7 +69,7 @@ endif(REGEDIT)
|
||||
|
||||
|
||||
if (USE_HDF5)
|
||||
target_include_directories(dispatch PRIVATE ${HDF5_INCLUDE_DIR})
|
||||
target_link_libraries(dispatch PRIVATE HDF5::HDF5)
|
||||
endif(USE_HDF5)
|
||||
|
||||
if(STATUS_PARALLEL)
|
||||
|
@ -28,7 +28,7 @@ if(STATUS_PARALLEL)
|
||||
target_link_libraries(netcdfhdf5 PUBLIC MPI::MPI_C)
|
||||
endif(STATUS_PARALLEL)
|
||||
|
||||
target_include_directories(netcdfhdf5 PUBLIC ${HDF5_INCLUDE_DIR})
|
||||
target_link_libraries(netcdfhdf5 PUBLIC HDF5::HDF5)
|
||||
|
||||
# Remember to package this file for CMake builds.
|
||||
add_extra_dist(${libnchdf5_SOURCES} CMakeLists.txt)
|
||||
|
@ -140,23 +140,7 @@ if(ENABLE_NCZARR_ZIP)
|
||||
endif()
|
||||
|
||||
if(USE_HDF5)
|
||||
if(NOT MSVC)
|
||||
# Some version of cmake define HDF5_hdf5_LIBRARY instead of
|
||||
# HDF5_LIBRARY. Same with HDF5_HL_LIBRARIES
|
||||
if(HDF5_hdf5_LIBRARY AND NOT HDF5_C_LIBRARIES)
|
||||
set(HDF5_C_LIBRARIES ${HDF5_hdf5_LIBRARY})
|
||||
endif()
|
||||
if(HDF5_hdf5_hl_LIBRARY AND NOT HDF5_HL_LIBRARIES)
|
||||
set(HDF5_HL_LIBRARIES ${HDF5_hdf5_hl_LIBRARY})
|
||||
endif()
|
||||
# The order of the libraries is important here for static
|
||||
# builds:
|
||||
# Make sure that HDF5_C_LIBRARY appears *after*
|
||||
# HDF5_HL_LIBRARY.
|
||||
set(TLL_LIBS ${HDF5_HL_LIBRARIES} ${HDF5_C_LIBRARIES} ${HDF5_LIBRARIES} ${TLL_LIBS} ${Szip_LIBRARY})
|
||||
else() # Windows CMake defines HDF5_LIBRARIES.
|
||||
set(TLL_LIBS ${HDF5_LIBRARIES} ${TLL_LIBS} ${Szip_LIBRARY})
|
||||
endif()
|
||||
set(TLL_LIBS HDF5::HDF5 hdf5::hdf5_hl ${TLL_LIBS} ${Szip_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(FOUND_CURL)
|
||||
@ -234,4 +218,4 @@ set(NC_LIBS ${NC_LIBS} PARENT_SCOPE)
|
||||
|
||||
file(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/*.c)
|
||||
set(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am)
|
||||
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")
|
||||
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")
|
||||
|
@ -62,7 +62,7 @@ add_library(nczarr OBJECT ${libnczarr_SOURCES})
|
||||
target_include_directories(nczarr PUBLIC ../libncpoco)
|
||||
|
||||
if (USE_HDF5)
|
||||
target_include_directories(nczarr PRIVATE ${HDF5_INCLUDE_DIR})
|
||||
target_link_libraries(nczarr PRIVATE HDF5::HDF5)
|
||||
endif(USE_HDF5)
|
||||
|
||||
if(STATUS_PARALLEL)
|
||||
|
@ -36,7 +36,7 @@ set(ARGS_MANPAGE -DAPI=C)
|
||||
|
||||
if (USE_HDF5)
|
||||
set(ARGS_MANPAGE ${ARGS_MANPAGE} -DNETCDF4=TRUE)
|
||||
target_include_directories(netcdf4 PRIVATE ${HDF5_INCLUDE_DIR})
|
||||
target_link_libraries(netcdf4 PRIVATE HDF5::HDF5)
|
||||
endif(USE_HDF5)
|
||||
|
||||
if (BUILD_DAP)
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_HDF5_H
|
||||
#ifdef USE_HDF5
|
||||
#include <hdf5.h>
|
||||
#endif
|
||||
#include "netcdf.h"
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_HDF5_H
|
||||
#ifdef USE_HDF5
|
||||
#include <hdf5.h>
|
||||
#endif
|
||||
#include "netcdf.h"
|
||||
|
@ -45,8 +45,13 @@ add_executable(ncfilteravail ${ncfilteravail_FILES})
|
||||
|
||||
if(USE_HDF5)
|
||||
add_executable(nc4print nc4print.c nc4printer.c)
|
||||
target_link_libraries(nc4print netcdf ${ALL_TLL_LIBS})
|
||||
|
||||
add_executable(printfqn ${printfqn_FILES})
|
||||
target_link_libraries(printfqn netcdf ${ALL_TLL_LIBS})
|
||||
|
||||
add_executable(nchdf5version ${nchdf5version_FILES})
|
||||
target_link_libraries(nchdf5version netcdf ${ALL_TLL_LIBS})
|
||||
endif(USE_HDF5)
|
||||
|
||||
if(ENABLE_DAP)
|
||||
@ -60,13 +65,6 @@ target_link_libraries(ncvalidator netcdf ${ALL_TLL_LIBS})
|
||||
target_link_libraries(ncpathcvt netcdf ${ALL_TLL_LIBS})
|
||||
target_link_libraries(ncfilteravail netcdf ${ALL_TLL_LIBS})
|
||||
|
||||
if(USE_HDF5)
|
||||
target_link_libraries(nc4print netcdf ${ALL_TLL_LIBS})
|
||||
target_link_libraries(printfqn netcdf ${ALL_TLL_LIBS})
|
||||
target_link_libraries(nchdf5version netcdf ${ALL_TLL_LIBS})
|
||||
target_include_directories(ncdump PRIVATE ${HDF5_INCLUDE_DIR})
|
||||
endif(USE_HDF5)
|
||||
|
||||
if(ENABLE_DAP)
|
||||
target_link_libraries(ocprint netcdf ${ALL_TLL_LIBS})
|
||||
endif(ENABLE_DAP)
|
||||
@ -127,7 +125,7 @@ endif()
|
||||
|
||||
IF(USE_HDF5)
|
||||
add_executable(tst_fileinfo tst_fileinfo.c)
|
||||
target_link_libraries(tst_fileinfo netcdf)
|
||||
target_link_libraries(tst_fileinfo netcdf ${ALL_TLL_LIBS})
|
||||
ENDIF()
|
||||
|
||||
IF(MSVC)
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "ncpathmgr.h"
|
||||
#include "nclog.h"
|
||||
|
||||
#ifdef HAVE_HDF5_H
|
||||
#ifdef USE_HDF5
|
||||
#include <hdf5.h>
|
||||
#include <H5DSpublic.h>
|
||||
#endif
|
||||
|
@ -8,11 +8,6 @@
|
||||
#include "ncpathmgr.h"
|
||||
#include "nclist.h"
|
||||
|
||||
#ifdef HAVE_HDF5_H
|
||||
#include <hdf5.h>
|
||||
#include <H5DSpublic.h>
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NCZARR
|
||||
#include "zincludes.h"
|
||||
#endif
|
||||
|
@ -9,11 +9,6 @@
|
||||
#include "ncpathmgr.h"
|
||||
#include "nclist.h"
|
||||
|
||||
#ifdef HAVE_HDF5_H
|
||||
#include <hdf5.h>
|
||||
#include <H5DSpublic.h>
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NCZARR
|
||||
#include "zincludes.h"
|
||||
#endif
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "XGetopt.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HDF5_H
|
||||
#ifdef USE_HDF5
|
||||
#include <hdf5.h>
|
||||
#include <H5DSpublic.h>
|
||||
#endif
|
||||
|
@ -38,15 +38,10 @@ data:
|
||||
\endcode
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_HDF5_H
|
||||
#include <hdf5.h>
|
||||
#endif
|
||||
|
||||
#include "netcdf.h"
|
||||
|
||||
/* The HDF assigned id for bzip compression */
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_HDF5_H
|
||||
#ifdef USE_HDF5
|
||||
#include <hdf5.h>
|
||||
#endif
|
||||
|
||||
|
@ -12,7 +12,7 @@ Test support for multiple filters per variable
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_HDF5_H
|
||||
#ifdef USE_HDF5
|
||||
#include <hdf5.h>
|
||||
#endif
|
||||
|
||||
|
@ -72,7 +72,7 @@ macro(buildplugin TARGET TARGETLIB)
|
||||
endif(STATUS_PARALLEL)
|
||||
|
||||
if (USE_HDF5)
|
||||
target_include_directories(${TARGET} PRIVATE ${HDF5_INCLUDE_DIR})
|
||||
target_link_libraries(${TARGET} PRIVATE HDF5::HDF5)
|
||||
endif(USE_HDF5)
|
||||
endmacro()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user