Merge branch 'master' into issue258

This commit is contained in:
Wei-keng Liao 2016-11-13 00:00:54 -06:00
commit e8cfdbb25a
5 changed files with 44 additions and 65 deletions

View File

@ -393,6 +393,33 @@ IF(NOT MSVC)
ENDIF(BUILD_FORTRAN)
ENDIF()
###
# Allow the user to specify libraries
# to link against, similar to automakes 'LIBS' variable.
###
SET(NC_EXTRA_DEPS "" CACHE STRING "Additional libraries to link against.")
IF(NC_EXTRA_DEPS)
STRING(REPLACE " " ";" DEPS_LIST ${NC_EXTRA_DEPS})
FOREACH(_DEP ${DEPS_LIST})
STRING(REGEX REPLACE "^-l" "" _LIB ${_DEP})
FIND_LIBRARY("${_LIB}_DEP" NAMES "${_LIB}" "lib${_LIB}")
MESSAGE(${${_LIB}_DEP})
IF(NOT "${_LIB}_DEP")
MESSAGE(FATAL_ERROR "Error finding ${_LIB}.")
ELSE()
MESSAGE(STATUS "Found ${_LIB}: ${${_LIB}_DEP}")
ENDIF()
SET(EXTRA_DEPS ${EXTRA_DEPS} "${${_LIB}_DEP}")
ENDFOREACH()
MESSAGE("Extra deps: ${EXTRA_DEPS}")
LIST(REMOVE_DUPLICATES EXTRA_DEPS)
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${EXTRA_DEPS})
ENDIF()
###
# End user-specified dependent libraries.
###
# Option to use HDF4
OPTION(ENABLE_HDF4 "Build netCDF-4 with HDF5 read capability(HDF4, HDF5 and Zlib required)." OFF)
IF(ENABLE_HDF4)
@ -640,6 +667,18 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
SET(HDF5_C_LIBRARY hdf5)
ENDIF(NOT MSVC)
#Check to see if H5Z_SZIP exists in HDF5_Libraries. If so, we must use szip.
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5P_SZIP "" USE_SZIP)
IF(USE_SZIP)
FIND_LIBRARY(SZIP NAMES szip sz)
IF(SZIP)
SET(SZIP_LIBRARY ${SZIP})
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${SZIP})
ELSE()
MESSAGE(FATAL_ERROR "HDF5 Requires SZIP, but cannot find libszip or libsz.")
ENDIF()
ENDIF()
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5free_memory "" HDF5_HAS_H5FREE)
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5Pset_libver_bounds "" HDF5_HAS_LIBVER_BOUNDS)
@ -649,15 +688,6 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
SET(HDF5_CC h5cc)
ENDIF()
# execute_process(COMMAND sh -c "${HDF5_CC} -showconfig | grep -i 'HDF5 version' | cut -d: -f2 | tr -d ' '"
# OUTPUT_VARIABLE HDF5_VERSION
# ERROR_QUIET)
# It cannot be assumed that libhdf5.settings exists. If it doesn't,
# the call to h5cc will have failed. At this point we will have to
# trust the user that they have configured their system properly.
# Starting with hdf5 1.8.11, dynamic loading is an option.
# In case hdf5 has a dependency on libdl, the user must specify
# -DENABLE_DYNAMIC_LOADING=ON when configuring netcdf.
@ -675,19 +705,6 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
INCLUDE_DIRECTORIES(${LIBDL_INCLUDE_DIR})
ENDIF()
#Check to see if H5Z_SZIP exists in HDF5_Libraries. If so, we must use szip.
CHECK_LIBRARY_EXISTS(hdf5 H5Z_SZIP "" USE_SZIP)
IF(USE_SZIP)
FIND_LIBRARY(SZIP NAMES szip sz)
IF(SZIP)
SET(SZIP_LIBRARY ${SZIP})
ELSE()
MESSAGE(FATAL_ERROR "HDF5 Requires SZIP, but cannot find libszip or libsz.")
ENDIF()
#FIND_PACKAGE(SZIP NO_MODULE REQUIRED)
#INCLUDE_DIRECTORIES(${SZIP_INCLUDE_DIR})
ENDIF()
SET(H5_USE_16_API 1)
OPTION(NC_ENABLE_HDF_16_API "Enable HDF5 1.6.x Compatibility(Required)" ON)
IF(NOT NC_ENABLE_HDF_16_API)
@ -863,32 +880,6 @@ IF(ENABLE_TESTS)
MARK_AS_ADVANCED(ENABLE_FAILING_TESTS)
ENDIF()
###
# Allow the user to specify libraries
# to link against, similar to automakes 'LIBS' variable.
###
SET(NC_EXTRA_DEPS "" CACHE STRING "Additional libraries to link against.")
IF(NC_EXTRA_DEPS)
STRING(REPLACE " " ";" DEPS_LIST ${NC_EXTRA_DEPS})
FOREACH(_DEP ${DEPS_LIST})
STRING(REGEX REPLACE "^-l" "" _LIB ${_DEP})
FIND_LIBRARY("${_LIB}_DEP" NAMES "${_LIB}" "lib${_LIB}")
MESSAGE(${${_LIB}_DEP})
IF(NOT "${_LIB}_DEP")
MESSAGE(FATAL_ERROR "Error finding ${_LIB}.")
ELSE()
MESSAGE(STATUS "Found ${_LIB}: ${${_LIB}_DEP}")
ENDIF()
SET(EXTRA_DEPS ${EXTRA_DEPS} "${${_LIB}_DEP}")
ENDFOREACH()
MESSAGE("Extra deps: ${EXTRA_DEPS}")
LIST(REMOVE_DUPLICATES EXTRA_DEPS)
ENDIF()
###
# End user-specified dependent libraries.
###
###
# Option to enable extreme numbers during testing.
###

View File

@ -81,7 +81,7 @@ IF(TLL_LIBS)
ENDIF()
TARGET_LINK_LIBRARIES(netcdf ${TLL_LIBS})
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${TLL_LIBS})
IF(MSVC)
SET_TARGET_PROPERTIES(netcdf PROPERTIES
LINK_FLAGS_DEBUG " /NODEFAULTLIB:MSVCRT"

View File

@ -1969,24 +1969,14 @@ write_nc3_strict_att(hid_t hdf_grpid)
int one = 1, num, a;
char att_name[NC_MAX_HDF5_NAME + 1];
int retval = NC_NOERR;
htri_t attr_exists;
/* If the attribute already exists, call that a success and return
* NC_NOERR. */
if ((num = H5Aget_num_attrs(hdf_grpid)) < 0)
if ((attr_exists = H5Aexists(hdf_grpid, NC3_STRICT_ATT_NAME)) < 0)
return NC_EHDFERR;
for (a = 0; a < num; a++)
{
if ((attid = H5Aopen_idx(hdf_grpid, (unsigned int)a)) < 0)
BAIL(NC_EHDFERR);
if (H5Aget_name(attid, NC_MAX_HDF5_NAME, att_name) < 0)
BAIL(NC_EHDFERR);
if (H5Aclose(attid) < 0)
return NC_EFILEMETA;
if (strcmp(att_name, NC3_STRICT_ATT_NAME)==0)
{
return NC_NOERR;
}
}
if (attr_exists)
return NC_NOERR;
/* Create the attribute to mark this as a file that needs to obey
* strict netcdf-3 rules. */

View File

@ -82,7 +82,6 @@ has_f03="no"
nfconf=$(which nf-config 2>/dev/null)
if [ -f "$nfconf" ]; then
echo "Using nf-config: $nfconf"
has_fortran="yes"
fc=`nf-config --fc`
fflags=`nf-config --fflags`

View File

@ -29,7 +29,6 @@ has_f03="no"
nfconf=$(which nf-config 2>/dev/null)
if [ -f "$nfconf" ]; then
echo "Using nf-config: $nfconf"
has_fortran="yes"
fc=`nf-config --fc`
fflags=`nf-config --fflags`