Skip to content

Commit 672c71c

Browse files
Merge pull request #232 from AlysonStahl-NOAA/as_hdf5
Check for HDF5 in Cmake
2 parents 746374b + 52938a1 commit 672c71c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cmake/FindNetCDF.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# - NetCDF_CONFIG_EXECUTABLE - the netcdf-config executable if found
1818
# - NetCDF_PARALLEL - Boolean True if NetCDF4 has parallel IO support via hdf5 and/or pnetcdf
1919
# - NetCDF_HAS_PNETCDF - Boolean True if NetCDF4 has pnetcdf support
20+
# - NetCDF_HAS_HDF5 - Boolean True if NetCDF4 has HDF5 support
2021
#
2122
# Deprecated Defines
2223
# - NetCDF_LIBRARIES - [Deprecated] Use NetCDF::NetCDF_<LANG> targets instead.
@@ -182,6 +183,13 @@ else()
182183
set(NetCDF_PARALLEL FALSE CACHE STRING "NetCDF has no parallel IO capability." FORCE)
183184
endif()
184185

186+
netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-hdf5 _val)
187+
if( _val MATCHES "^(yes)$" )
188+
set(NetCDF_HAS_HDF5 TRUE CACHE STRING "NetCDF has HDF5 enabled." FORCE)
189+
else()
190+
set(NetCDF_HAS_HDF5 FALSE CACHE STRING "NetCDF does not have HDF5 enabled." FORCE)
191+
endif()
192+
185193
if(NetCDF_PARALLEL)
186194
find_package(MPI REQUIRED)
187195
endif()
@@ -307,6 +315,7 @@ if( ${CMAKE_FIND_PACKAGE_NAME}_FOUND AND NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUI
307315
message( STATUS "Find${CMAKE_FIND_PACKAGE_NAME} defines targets:" )
308316
message( STATUS " - NetCDF_VERSION [${NetCDF_VERSION}]")
309317
message( STATUS " - NetCDF_PARALLEL [${NetCDF_PARALLEL}]")
318+
message( STATUS " - NetCDF_HAS_HDF5 [${NetCDF_HAS_HDF5}]")
310319
foreach( _comp IN LISTS _new_search_components )
311320
string( TOUPPER "${_comp}" _COMP )
312321
message( STATUS " - NetCDF_${_comp}_CONFIG_EXECUTABLE [${NetCDF_${_comp}_CONFIG_EXECUTABLE}]")
@@ -328,6 +337,7 @@ foreach( _prefix NetCDF NetCDF4 NETCDF NETCDF4 ${CMAKE_FIND_PACKAGE_NAME} )
328337
set( ${_prefix}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_FOUND} )
329338
set( ${_prefix}_CONFIG_EXECUTABLE ${NetCDF_CONFIG_EXECUTABLE} )
330339
set( ${_prefix}_PARALLEL ${NetCDF_PARALLEL} )
340+
set( ${_prefix}_HAS_HDF5 ${NetCDF_HAS_HDF5} )
331341

332342
foreach( _comp ${_search_components} )
333343
string( TOUPPER "${_comp}" _COMP )

0 commit comments

Comments
 (0)