2024-01-11 05:18:15 +08:00
################################
# PkgConfig
################################
2024-01-18 05:47:16 +08:00
find_package ( PkgConfig QUIET )
2024-01-11 05:18:15 +08:00
################################
# MakeDist
################################
# Enable 'dist and distcheck'.
# File adapted from http://ensc.de/cmake/FindMakeDist.cmake
2024-01-18 05:47:16 +08:00
find_package ( MakeDist )
2024-01-11 05:18:15 +08:00
# End 'enable dist and distcheck'
################################
# HDF4
################################
2024-01-18 05:47:16 +08:00
if ( ENABLE_HDF4 )
set ( USE_HDF4 ON )
2024-01-11 05:18:15 +08:00
# Check for include files, libraries.
2024-01-18 05:47:16 +08:00
find_path ( MFHDF_H_INCLUDE_DIR mfhdf.h )
if ( NOT MFHDF_H_INCLUDE_DIR )
message ( FATAL_ERROR "HDF4 Support specified, cannot find file mfhdf.h" )
else ( )
2024-01-19 23:25:24 +08:00
target_include_directories ( netcdf
P R I V A T E
$ { M F H D F _ H _ I N C L U D E _ D I R }
)
2024-01-18 05:47:16 +08:00
endif ( )
2024-01-11 05:18:15 +08:00
2024-01-18 05:47:16 +08:00
find_library ( HDF4_DF_LIB NAMES df libdf hdf )
if ( NOT HDF4_DF_LIB )
message ( FATAL_ERROR "Can't find or link to the hdf4 df library." )
endif ( )
2024-01-11 05:18:15 +08:00
2024-01-18 05:47:16 +08:00
find_library ( HDF4_MFHDF_LIB NAMES mfhdf libmfhdf )
if ( NOT HDF4_MFHDF_LIB )
message ( FATAL_ERROR "Can't find or link to the hdf4 mfhdf library." )
endif ( )
2024-01-11 05:18:15 +08:00
2024-01-18 05:47:16 +08:00
set ( HAVE_LIBMFHDF TRUE )
2024-01-11 05:18:15 +08:00
2024-01-18 05:47:16 +08:00
set ( HDF4_LIBRARIES ${ HDF4_DF_LIB } ${ HDF4_MFHDF_LIB } )
2024-01-11 05:18:15 +08:00
# End include files, libraries.
2024-01-18 05:47:16 +08:00
message ( STATUS "HDF4 libraries: ${HDF4_DF_LIB}, ${HDF4_MFHDF_LIB}" )
2024-01-11 05:18:15 +08:00
2024-01-18 05:47:16 +08:00
message ( STATUS "Seeking HDF4 jpeg dependency." )
2024-01-11 05:18:15 +08:00
# Look for the jpeglib.h header file.
2024-01-18 05:47:16 +08:00
find_path ( JPEGLIB_H_INCLUDE_DIR jpeglib.h )
if ( NOT JPEGLIB_H_INCLUDE_DIR )
message ( FATAL_ERROR "HDF4 Support enabled but cannot find jpeglib.h" )
else ( )
set ( HAVE_JPEGLIB_H ON CACHE BOOL "" )
set ( HAVE_LIBJPEG TRUE )
2024-01-19 23:25:24 +08:00
target_include_directories ( netcdf
P R I V A T E
$ { J P E G L I B _ H _ I N C L U D E _ D I R }
)
2024-01-18 05:47:16 +08:00
endif ( )
find_library ( JPEG_LIB NAMES jpeg libjpeg )
if ( NOT JPEG_LIB )
message ( FATAL_ERROR "HDF4 Support enabled but cannot find libjpeg" )
endif ( )
set ( HDF4_LIBRARIES ${ JPEG_LIB } ${ HDF4_LIBRARIES } )
message ( STATUS "Found JPEG libraries: ${JPEG_LIB}" )
2024-01-11 05:18:15 +08:00
# Option to enable HDF4 file tests.
2024-01-18 23:15:20 +08:00
option ( ENABLE_HDF4_FILE_TESTS "Run HDF4 file tests. This fetches sample HDF4 files from the Unidata ftp site to test with (requires curl)." ON )
2024-01-18 05:47:16 +08:00
if ( ENABLE_HDF4_FILE_TESTS )
2024-01-18 23:15:20 +08:00
find_program ( PROG_CURL NAMES curl )
2024-01-18 05:47:16 +08:00
if ( PROG_CURL )
set ( USE_HDF4_FILE_TESTS ON )
else ( )
message ( STATUS "Unable to locate 'curl'. Disabling hdf4 file tests." )
set ( USE_HDF4_FILE_TESTS OFF )
endif ( )
set ( USE_HDF4_FILE_TESTS ${ USE_HDF4_FILE_TESTS } )
endif ( )
endif ( )
2024-01-11 05:18:15 +08:00
################################
# HDF5
################################
##
# Option to Enable HDF5
#
# The HDF5 cmake variables differ between platform (linux/osx and Windows),
# as well as between HDF5 versions. As a result, this section is a bit convoluted.
#
# Note that the behavior seems much more stable across HDF5 versions under linux,
# so we do not have to do as much version-based tweaking.
#
# At the end of it, we should have the following defined:
#
# * HDF5_C_LIBRARY
# * HDF5_HL_LIBRARY
# * HDF5_LIBRARIES
# * HDF5_INCLUDE_DIR
# *
##
2024-01-18 05:47:16 +08:00
if ( USE_HDF5 )
2024-01-11 05:18:15 +08:00
##
# Assert HDF5 version meets minimum required version.
##
2024-01-18 05:47:16 +08:00
set ( HDF5_VERSION_REQUIRED 1.8.10 )
2024-01-11 05:18:15 +08:00
##
# 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.
##
2024-01-18 05:47:16 +08:00
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 } )
2024-01-19 23:25:24 +08:00
target_include_directories ( netcdf
2024-02-16 06:51:38 +08:00
P R I V A T E
2024-01-19 23:25:24 +08:00
$ { H D F 5 _ I N C L U D E _ D I R }
)
2024-01-18 05:47:16 +08:00
message ( STATUS "Using HDF5 C Library: ${HDF5_C_LIBRARY}" )
message ( STATUS "Using HDF5 HL LIbrary: ${HDF5_HL_LIBRARY}" )
2024-01-11 05:18:15 +08:00
if ( EXISTS "${HDF5_INCLUDE_DIR}/H5pubconf.h" )
file ( READ "${HDF5_INCLUDE_DIR}/H5pubconf.h" _hdf5_version_lines
R E G E X " #define[ \t]+H5_VERSION")
string ( REGEX REPLACE ".*H5_VERSION .*\" \(.*\)\".*" "\\1" _hdf5_version "${_hdf5_version_lines}" )
set ( HDF5_VERSION "${_hdf5_version}" CACHE STRING "" )
2024-01-11 06:11:00 +08:00
set ( HDF5_VERSION ${ HDF5_VERSION } PARENT_SCOPE )
2024-01-11 05:18:15 +08:00
unset ( _hdf5_version )
unset ( _hdf5_version_lines )
endif ( )
2024-01-18 05:47:16 +08:00
message ( STATUS "Found HDF5 libraries version ${HDF5_VERSION}" )
2024-01-11 05:18:15 +08:00
###
# If HDF5_VERSION is still empty, we have a problem.
# Error out.
###
2024-01-18 05:47:16 +08:00
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 ( )
2024-01-11 05:18:15 +08:00
###
# Now that we know HDF5_VERSION isn't empty, we can check for minimum required version,
# and toggle various options.
###
2024-01-18 05:47:16 +08:00
if ( ${ HDF5_VERSION } VERSION_LESS ${ HDF5_VERSION_REQUIRED } )
message ( FATAL_ERROR "netCDF requires at least HDF5 ${HDF5_VERSION_REQUIRED}. Found ${HDF5_VERSION}." )
endif ( )
2024-01-11 05:18:15 +08:00
2024-01-18 05:47:16 +08:00
else ( HDF5_C_LIBRARY AND HDF5_HL_LIBRARY AND HDF5_INCLUDE_DIR ) # We are seeking out HDF5 with Find Package.
2024-01-11 05:18:15 +08:00
###
# 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.
##
2024-01-18 05:47:16 +08:00
if ( NC_FIND_SHARED_LIBS )
2024-01-18 22:34:30 +08:00
set ( HDF5_USE_STATIC_LIBRARIES OFF )
2024-01-18 05:47:16 +08:00
else ( NC_FIND_SHARED_LIBS )
2024-01-18 22:34:30 +08:00
set ( HDF5_USE_STATIC_LIBRARIES ON )
2024-01-18 05:47:16 +08:00
endif ( NC_FIND_SHARED_LIBS )
2024-01-11 05:18:15 +08:00
#####
# First, find the C and HL libraries.
#####
2024-01-18 22:34:30 +08:00
find_package ( HDF5 ${ HDF5_VERSION_REQUIRED } COMPONENTS C HL REQUIRED )
2024-01-11 05:18:15 +08:00
##
# Include the HDF5 include directory.
##
2024-01-18 05:47:16 +08:00
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}" )
2024-01-19 23:25:24 +08:00
target_include_directories ( netcdf
2024-02-16 06:51:38 +08:00
P R I V A T E
2024-01-19 23:25:24 +08:00
$ { H D F 5 _ I N C L U D E _ D I R }
)
2024-01-11 05:18:15 +08:00
###
# 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.
###
2024-01-18 05:47:16 +08:00
if ( MSVC )
2024-01-11 05:18:15 +08:00
####
# Environmental variables in Windows when using MSVC
# are a hot mess between versions.
####
##
# HDF5 1.8.15 defined HDF5_LIBRARIES.
##
2024-01-18 05:47:16 +08:00
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" )
2024-01-11 05:18:15 +08:00
2024-01-18 05:47:16 +08:00
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} )
2024-01-11 05:18:15 +08:00
2024-01-18 05:47:16 +08:00
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" )
2024-01-11 05:18:15 +08:00
2024-01-18 05:47:16 +08:00
else ( MSVC )
2024-01-11 05:18:15 +08:00
# Depending on the install, either HDF5_hdf_library or
# HDF5_C_LIBRARIES may be defined. We must check for either.
2024-01-18 05:47:16 +08:00
if ( HDF5_C_LIBRARIES AND NOT HDF5_hdf5_LIBRARY )
set ( HDF5_hdf5_LIBRARY ${ HDF5_C_LIBRARIES } )
endif ( )
2024-01-11 05:18:15 +08:00
2024-01-18 05:47:16 +08:00
# Some versions of find_package set HDF5_C_LIBRARIES, but not HDF5_C_LIBRARY
2024-01-11 05:18:15 +08:00
# We use HDF5_C_LIBRARY below, so need to make sure it is set.
2024-01-18 05:47:16 +08:00
if ( HDF5_C_LIBRARIES AND NOT HDF5_C_LIBRARY )
set ( HDF5_C_LIBRARY ${ HDF5_C_LIBRARIES } )
endif ( )
2024-01-11 05:18:15 +08:00
# Same issue as above...
2024-01-18 05:47:16 +08:00
if ( HDF5_HL_LIBRARIES AND NOT HDF5_HL_LIBRARY )
set ( HDF5_HL_LIBRARY ${ HDF5_HL_LIBRARIES } )
endif ( )
2024-01-11 05:18:15 +08:00
2024-01-18 05:47:16 +08:00
endif ( MSVC )
if ( NOT HDF5_C_LIBRARY )
set ( HDF5_C_LIBRARY hdf5 )
endif ( )
2024-01-11 05:18:15 +08:00
2024-01-18 05:47:16 +08:00
endif ( HDF5_C_LIBRARY AND HDF5_HL_LIBRARY AND HDF5_INCLUDE_DIR )
2024-01-11 05:18:15 +08:00
2024-01-18 05:47:16 +08:00
find_package ( Threads )
2024-01-11 05:18:15 +08:00
# There is a missing case in the above code so default it
2024-01-18 05:47:16 +08:00
if ( NOT HDF5_C_LIBRARY_hdf5 OR "${HDF5_C_LIBRARY_hdf5}" STREQUAL "" )
set ( HDF5_C_LIBRARY_hdf5 "${HDF5_C_LIBRARY}" )
endif ( )
2024-01-11 05:18:15 +08:00
2023-10-06 23:39:39 +08:00
include ( cmake/check_hdf5.cmake )
2024-01-11 05:18:15 +08:00
# 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.
2024-01-19 07:50:28 +08:00
2023-10-06 23:39:39 +08:00
check_hdf5_feature ( HAVE_HDF5_ZLIB H5_HAVE_ZLIB_H )
2024-01-18 05:47:16 +08:00
if ( NOT HAVE_HDF5_ZLIB )
message ( FATAL_ERROR "HDF5 was built without zlib. Rebuild HDF5 with zlib." )
else ( )
2024-01-11 05:18:15 +08:00
# If user has specified the `ZLIB_LIBRARY`, use it; otherwise try to find...
2024-01-18 05:47:16 +08:00
if ( NOT ZLIB_LIBRARY )
2024-01-11 05:18:15 +08:00
find_package ( ZLIB )
2024-01-18 05:47:16 +08:00
if ( ZLIB_FOUND )
set ( ZLIB_LIBRARY ${ ZLIB_LIBRARIES } )
else ( )
message ( FATAL_ERROR "HDF5 Requires ZLIB, but cannot find libz." )
endif ( )
endif ( )
set ( CMAKE_REQUIRED_LIBRARIES ${ ZLIB_LIBRARY } ${ CMAKE_REQUIRED_LIBRARIES } )
message ( STATUS "HDF5 has zlib." )
endif ( )
2024-01-11 05:18:15 +08:00
2023-10-06 23:39:39 +08:00
# Check to see if H5Z_SZIP exists in HDF5_Libraries. If so, we must use szip library.
check_hdf5_feature ( HAVE_H5Z_SZIP H5_HAVE_FILTER_SZIP )
2024-01-11 05:18:15 +08:00
####
# Check to see if HDF5 library is 1.10.6 or greater.
# Used to control path name conversion
####
2024-01-18 05:47:16 +08:00
if ( ${ HDF5_VERSION } VERSION_GREATER "1.10.5" )
set ( HDF5_UTF8_PATHS ON )
else ( )
set ( HDF5_UTF8_PATHS OFF )
endif ( )
2024-01-11 05:18:15 +08:00
2024-01-18 05:47:16 +08:00
message ( "-- HDF5_UTF8_PATHS (HDF5 version 1.10.6+): ${HDF5_UTF8_PATHS}" )
2024-01-11 05:18:15 +08:00
# 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}.
# 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 )
2024-01-18 05:47:16 +08:00
if ( HDF5_IS_PARALLEL_MPIO )
set ( HDF5_PARALLEL ON )
else ( )
set ( HDF5_PARALLEL OFF )
endif ( )
set ( HDF5_PARALLEL ${ HDF5_PARALLEL } )
2024-01-11 05:18:15 +08:00
#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 )
2024-01-18 05:47:16 +08:00
if ( HDF5_PARALLEL )
set ( HDF5_CC h5pcc )
else ( )
set ( HDF5_CC h5cc )
endif ( )
2024-01-11 05:18:15 +08:00
# Check to see if H5Dread_chunk is available
CHECK_LIBRARY_EXISTS ( ${ HDF5_C_LIBRARY_hdf5 } H5Dread_chunk "" 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 to see if this is hdf5-1.10.3 or later.
2024-01-18 05:47:16 +08:00
if ( HAS_READCHUNKS )
set ( HDF5_SUPPORTS_PAR_FILTERS ON )
set ( ENABLE_NCDUMPCHUNKS ON )
endif ( )
2024-01-11 05:18:15 +08:00
# Record if ROS3 Driver is available
2024-01-18 05:47:16 +08:00
if ( HAS_HDF5_ROS3 )
set ( ENABLE_HDF5_ROS3 ON )
endif ( )
2024-01-11 05:18:15 +08:00
IF ( HDF5_SUPPORTS_PAR_FILTERS )
2024-01-18 05:47:16 +08:00
set ( HDF5_HAS_PAR_FILTERS TRUE CACHE BOOL "" )
set ( HAS_PAR_FILTERS yes CACHE STRING "" )
else ( )
set ( HDF5_HAS_PAR_FILTERS FALSE CACHE BOOL "" )
set ( HAS_PAR_FILTERS no CACHE STRING "" )
endif ( )
2024-01-18 22:35:19 +08:00
set ( HAVE_HDF5_H ${ HDF5_C_INCLUDE_DIR } )
target_include_directories ( netcdf
P R I V A T E
$ { H A V E _ H D F 5 _ H }
)
2024-01-11 05:18:15 +08:00
#option to include HDF5 High Level header file (hdf5_hl.h) in case we are not doing a make install
2024-01-19 23:25:24 +08:00
target_include_directories ( netcdf
2024-02-16 06:51:38 +08:00
P R I V A T E
2024-01-19 23:25:24 +08:00
$ { H D F 5 _ H L _ I N C L U D E _ D I R }
)
2024-01-11 05:18:15 +08:00
2024-01-18 05:47:16 +08:00
endif ( USE_HDF5 )
2024-01-11 05:18:15 +08:00
################################
# Curl
################################
# See if we have libcurl
2024-01-18 05:47:16 +08:00
find_package ( CURL )
2024-01-19 23:25:24 +08:00
target_compile_options ( netcdf
P R I V A T E
- D C U R L _ S T A T I C L I B = 1
)
target_include_directories ( netcdf
P R I V A T E
$ { C U R L _ I N C L U D E _ D I R S }
)
2024-01-11 05:18:15 +08:00
# Define a test flag for have curl library
2024-01-18 05:47:16 +08:00
if ( CURL_LIBRARIES OR CURL_LIBRARY )
set ( FOUND_CURL TRUE )
else ( )
set ( FOUND_CURL FALSE )
endif ( )
set ( FOUND_CURL ${ FOUND_CURL } TRUE )
2024-01-11 05:18:15 +08:00
# Start disabling if curl not found
2024-01-18 05:47:16 +08:00
if ( NOT FOUND_CURL )
message ( WARNING "ENABLE_REMOTE_FUNCTIONALITY requires libcurl; disabling" )
set ( ENABLE_REMOTE_FUNCTIONALITY OFF CACHE BOOL "ENABLE_REMOTE_FUNCTIONALITY requires libcurl; disabling" FORCE )
endif ( )
2024-01-11 05:18:15 +08:00
set ( CMAKE_REQUIRED_INCLUDES ${ CURL_INCLUDE_DIRS } )
# Check to see if we have libcurl 7.66 or later
CHECK_C_SOURCE_COMPILES ( "
#include <curl/curl.h>
i n t main ( ) {
#if LIBCURL_VERSION_NUM < 0x074200
c h o k e m e ;
#endif
} " H A V E _ L I B C U R L _ 7 6 6 )
IF ( HAVE_LIBCURL_766 )
# If libcurl version is >= 7.66, then can skip tests
# for these symbols which were added in an earlier version
set ( HAVE_CURLOPT_USERNAME TRUE )
set ( HAVE_CURLOPT_PASSWORD TRUE )
set ( HAVE_CURLOPT_KEYPASSWD TRUE )
set ( HAVE_CURLINFO_RESPONSE_CODE TRUE )
set ( HAVE_CURLINFO_HTTP_CONNECTCODE TRUE )
set ( HAVE_CURLOPT_BUFFERSIZE TRUE )
set ( HAVE_CURLOPT_KEEPALIVE TRUE )
2024-01-18 05:47:16 +08:00
else ( )
2024-01-11 05:18:15 +08:00
# Check to see if CURLOPT_USERNAME is defined.
# It is present starting version 7.19.1.
CHECK_C_SOURCE_COMPILES ( "
#include <curl/curl.h>
i n t main ( ) { i n t x = C U R L O P T _ U S E R N A M E ; } " H A V E _ C U R L O P T _ U S E R N A M E )
# Check to see if CURLOPT_PASSWORD is defined.
# It is present starting version 7.19.1.
CHECK_C_SOURCE_COMPILES ( "
#include <curl/curl.h>
i n t main ( ) { i n t x = C U R L O P T _ P A S S W O R D ; } " H A V E _ C U R L O P T _ P A S S W O R D )
# Check to see if CURLOPT_KEYPASSWD is defined.
# It is present starting version 7.16.4.
CHECK_C_SOURCE_COMPILES ( "
#include <curl/curl.h>
i n t main ( ) { i n t x = C U R L O P T _ K E Y P A S S W D ; } " H A V E _ C U R L O P T _ K E Y P A S S W D )
# Check to see if CURLINFO_RESPONSE_CODE is defined.
# It showed up in curl 7.10.7.
CHECK_C_SOURCE_COMPILES ( "
#include <curl/curl.h>
i n t main ( ) { i n t x = C U R L I N F O _ R E S P O N S E _ C O D E ; } " H A V E _ C U R L I N F O _ R E S P O N S E _ C O D E )
# Check to see if CURLINFO_HTTP_CONNECTCODE is defined.
# It showed up in curl 7.10.7.
CHECK_C_SOURCE_COMPILES ( "
#include <curl/curl.h>
i n t main ( ) { i n t x = C U R L I N F O _ H T T P _ C O N N E C T C O D E ; } " H A V E _ C U R L I N F O _ H T T P _ C O N N E C T C O D E )
# Check to see if CURLOPT_BUFFERSIZE is defined.
# It is present starting version 7.59
CHECK_C_SOURCE_COMPILES ( "
#include <curl/curl.h>
i n t main ( ) { i n t x = C U R L O P T _ B U F F E R S I Z E ; } " H A V E _ C U R L O P T _ B U F F E R S I Z E )
# Check to see if CURLOPT_TCP_KEEPALIVE is defined.
# It is present starting version 7.25
CHECK_C_SOURCE_COMPILES ( "
#include <curl/curl.h>
i n t main ( ) { i n t x = C U R L O P T _ T C P _ K E E P A L I V E ; } " H A V E _ C U R L O P T _ K E E P A L I V E )
2024-01-18 05:47:16 +08:00
endif ( )
2024-01-11 05:18:15 +08:00
################################
# Math
################################
# Check for the math library so it can be explicitly linked.
2024-01-18 05:47:16 +08:00
if ( NOT WIN32 )
find_library ( HAVE_LIBM NAMES math m libm )
if ( NOT HAVE_LIBM )
2024-01-11 05:18:15 +08:00
CHECK_FUNCTION_EXISTS ( exp HAVE_LIBM_FUNC )
2024-01-18 05:47:16 +08:00
if ( NOT HAVE_LIBM_FUNC )
message ( FATAL_ERROR "Unable to find the math library." )
else ( NOT HAVE_LIBM_FUNC )
set ( HAVE_LIBM "" )
endif ( )
else ( NOT HAVE_LIBM )
message ( STATUS "Found Math library: ${HAVE_LIBM}" )
endif ( )
endif ( )
2024-01-11 05:18:15 +08:00
################################
# zlib
################################
# See if we have zlib
2024-01-18 05:47:16 +08:00
find_package ( ZLIB )
2024-01-11 05:18:15 +08:00
# Define a test flag for have zlib library
2024-01-18 05:47:16 +08:00
if ( ZLIB_FOUND )
2024-01-19 23:25:24 +08:00
target_include_directories ( netcdf
P R I V A T E
$ { Z L I B _ I N C L U D E _ D I R S }
)
2024-01-18 05:47:16 +08:00
set ( ENABLE_ZLIB TRUE )
else ( )
set ( ENABLE_ZLIB FALSE )
endif ( )
2024-01-11 05:18:15 +08:00
################################
# Zips
################################
IF ( ENABLE_FILTER_SZIP )
2024-01-18 05:47:16 +08:00
find_package ( Szip )
elseif ( ENABLE_NCZARR )
find_package ( Szip )
endif ( )
2024-01-11 05:18:15 +08:00
IF ( ENABLE_FILTER_BZ2 )
2024-01-18 05:47:16 +08:00
find_package ( Bz2 )
endif ( )
2024-01-11 05:18:15 +08:00
IF ( ENABLE_FILTER_BLOSC )
2024-01-18 05:47:16 +08:00
find_package ( Blosc )
endif ( )
2024-01-11 05:18:15 +08:00
IF ( ENABLE_FILTER_ZSTD )
2024-01-18 05:47:16 +08:00
find_package ( Zstd )
endif ( )
2024-01-11 05:18:15 +08:00
# Accumulate standard filters
set ( STD_FILTERS "deflate" ) # Always have deflate*/
set_std_filter ( Szip )
2024-01-18 05:47:16 +08:00
set ( HAVE_SZ ${ Szip_FOUND } )
set ( USE_SZIP ${ HAVE_SZ } )
2024-01-11 05:18:15 +08:00
set_std_filter ( Blosc )
2024-01-18 05:47:16 +08:00
if ( Zstd_FOUND )
2024-01-11 05:18:15 +08:00
set_std_filter ( Zstd )
2024-01-18 05:47:16 +08:00
set ( HAVE_ZSTD ON )
endif ( )
if ( Bz2_FOUND )
2024-01-11 05:18:15 +08:00
set_std_filter ( Bz2 )
2024-01-18 05:47:16 +08:00
else ( )
2024-01-11 05:18:15 +08:00
# The reason we use a local version is to support a more comples test case
2024-01-18 05:47:16 +08:00
message ( "libbz2 not found using built-in version" )
set ( HAVE_LOCAL_BZ2 ON )
set ( HAVE_BZ2 ON CACHE BOOL "" )
2024-01-11 05:18:15 +08:00
set ( STD_FILTERS "${STD_FILTERS} bz2" )
2024-01-18 05:47:16 +08:00
endif ( )
2024-01-11 05:18:15 +08:00
IF ( ENABLE_NCZARR_ZIP )
2024-01-18 05:47:16 +08:00
find_package ( Zip REQUIRED )
2024-01-19 23:25:24 +08:00
target_include_directories ( netcdf
P R I V A T E
$ { Z i p _ I N C L U D E _ D I R S }
)
2024-01-18 05:47:16 +08:00
endif ( )
2024-01-11 05:18:15 +08:00
################################
# S3
################################
# Note we check for the library after checking for enable_s3
# because for some reason this screws up if we unconditionally test for sdk
# and it is not available. Fix someday
2024-01-18 05:47:16 +08:00
if ( ENABLE_S3 )
if ( NOT ENABLE_S3_INTERNAL )
2024-01-11 05:18:15 +08:00
# See if aws-s3-sdk is available
find_package ( AWSSDK REQUIRED COMPONENTS s3;transfer )
2024-01-18 05:47:16 +08:00
if ( AWSSDK_FOUND )
set ( ENABLE_S3_AWS ON CACHE BOOL "S3 AWS" FORCE )
2024-01-19 23:25:24 +08:00
target_include_directories ( netcdf
P R I V A T E
$ { A W S S D K _ I N C L U D E _ D I R }
)
2024-01-18 05:47:16 +08:00
else ( AWSSDK_FOUND )
set ( ENABLE_S3_AWS OFF CACHE BOOL "S3 AWS" FORCE )
endif ( AWSSDK_FOUND )
else ( NOT ENABLE_S3_INTERNAL )
2024-01-11 05:18:15 +08:00
# Find crypto libraries required with testing with the internal s3 api.
2024-01-18 05:47:16 +08:00
#find_library(SSL_LIB NAMES ssl openssl)
2024-01-11 05:18:15 +08:00
find_package ( OpenSSL REQUIRED )
2024-01-18 05:47:16 +08:00
if ( NOT OpenSSL_FOUND )
message ( FATAL_ERROR "Can't find an ssl library, required by S3_INTERNAL" )
endif ( NOT OpenSSL_FOUND )
2024-01-11 05:18:15 +08:00
#find_package(Crypto REQUIRED)
2024-01-18 05:47:16 +08:00
#if(NOT CRYPTO_LIB)
# message(FATAL_ERROR "Can't find a crypto library, required by S3_INTERNAL")
#endif(NOT CRYPTO_LIB)
2024-01-11 05:18:15 +08:00
2024-01-18 05:47:16 +08:00
endif ( NOT ENABLE_S3_INTERNAL )
else ( )
set ( ENABLE_S3_AWS OFF CACHE BOOL "S3 AWS" FORCE )
endif ( )
2024-01-11 05:18:15 +08:00
################################
# LibXML
################################
# see if we have libxml2
2024-01-18 05:47:16 +08:00
if ( ENABLE_LIBXML2 )
2024-01-11 05:18:15 +08:00
find_package ( LibXml2 )
2024-01-18 05:47:16 +08:00
if ( LibXml2_FOUND )
set ( HAVE_LIBXML2 TRUE )
2024-01-19 23:25:24 +08:00
target_include_directories ( netcdf
P R I V A T E
$ { L I B X M L 2 _ I N C L U D E _ D I R S }
)
2024-01-18 05:47:16 +08:00
set ( XMLPARSER "libxml2" )
else ( )
set ( HAVE_LIBXML2 FALSE )
endif ( )
endif ( ENABLE_LIBXML2 )
2024-01-11 05:18:15 +08:00
################################
# MPI
################################
2024-01-18 05:47:16 +08:00
if ( ENABLE_PARALLEL4 OR HDF5_PARALLEL )
find_package ( MPI REQUIRED )
endif ( )
2024-01-11 05:18:15 +08:00
################################
# parallel IO
################################
2024-01-18 05:47:16 +08:00
if ( ENABLE_PNETCDF )
find_library ( PNETCDF NAMES pnetcdf )
find_path ( PNETCDF_INCLUDE_DIR pnetcdf.h )
if ( NOT PNETCDF )
message ( STATUS "Cannot find PnetCDF library. Disabling PnetCDF support." )
set ( USE_PNETCDF OFF CACHE BOOL "" )
endif ( )
endif ( )
2024-01-11 05:18:15 +08:00
################################
# Doxygen
################################
2024-01-19 07:50:28 +08:00
2024-01-18 05:47:16 +08:00
if ( ENABLE_DOXYGEN )
find_package ( Doxygen REQUIRED )
2024-01-18 23:15:20 +08:00
endif ( )
################################
# NC_DPKG
################################
if ( NETCDF_PACKAGE )
find_program ( NC_DPKG NAMES dpkg )
2024-01-19 07:50:28 +08:00
endif ( )