Skip to content

Commit

Permalink
Merge pull request #27 from climbfuji/netcdf_static_fix
Browse files Browse the repository at this point in the history
NetCDF static fix
  • Loading branch information
mark-a-potts authored Feb 28, 2020
2 parents 4db1a06 + a49558c commit 994d66f
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions Modules/FindNetCDF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,28 @@ if (NETCDF_META)
endif (NETCDF_META)

find_library (NETCDF_flib
names libnetcdff.a netcdff.a libnetcdff.so netcdff.so libnetcdff.dylib netcdff.dylib
names libnetcdff.so netcdff.so libnetcdff.dylib netcdff.dylib libnetcdff.a netcdff.a
HINTS
${NETCDF_DIR}/lib
${NETCDF_FORTRAN_DIR}/lib
${NETCDF_FORTRAN}/lib
${NETCDF_FORTRAN_ROOT}/lib
${NETCDF_DIR}/lib64
${NETCDF_FORTRAN_DIR}/lib64
${NETCDF_FORTRAN}/lib64
${NETCDF_FORTRAN_ROOT}/lib64
)

if (NETCDF_flib)
get_filename_component(NETCDF_flib_ext ${NETCDF_flib} EXT)
if(NETCDF_flib_ext STREQUAL ".a")
set(NETCDF_IS_STATIC TRUE)
else()
set(NETCDF_IS_STATIC FALSE)
endif()
set(NETCDF_F90 "YES")

endif()
find_library (NETCDF_LIBRARIES_C
find_library (NETCDF_LIBRARIES_C
NAMES netcdf
HINTS ${NETCDF_DIR}/lib )
mark_as_advanced(NETCDF_LIBRARIES_C)
Expand Down Expand Up @@ -174,6 +183,13 @@ if( NETCDF_LIBRARIES_F90 )
endif()

set (NETCDF_LIBRARIES "${NetCDF_libs}" CACHE STRING "All NetCDF libraries required for interface level")

if(NETCDF_IS_STATIC)
find_package(HDF5 MODULE COMPONENTS C HL REQUIRED)
find_package(ZLIB MODULE REQUIRED)
set(NETCDF_LIBRARIES "${NETCDF_LIBRARIES};${HDF5_HL_LIBRARIES};${HDF5_LIBRARIES};${ZLIB_LIBRARIES}")
endif()

# handle the QUIETLY and REQUIRED arguments and set NETCDF_FOUND to TRUE if
# all listed variables are TRUE
include (FindPackageHandleStandardArgs)
Expand Down

0 comments on commit 994d66f

Please sign in to comment.