revise #1033 and emulate CMAKE OPTION to use 3rd option AUTO

This commit is contained in:
Wei-keng Liao 2018-07-01 19:42:03 -05:00
parent 68fb79daea
commit 26f1d9137c
2 changed files with 29 additions and 13 deletions

View File

@ -767,12 +767,6 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
ENDIF(USE_HDF5 OR ENABLE_NETCDF_4)
# Option to turn on CDF5 support.
OPTION(ENABLE_CDF5 "Enable CDF5 Support." ON)
IF(ENABLE_CDF5)
SET(USE_CDF5 ON CACHE BOOL "")
ENDIF(ENABLE_CDF5)
# Option to Build DAP2+DAP4 Clients
OPTION(ENABLE_DAP "Enable DAP2 and DAP4 Client." ON)
IF(ENABLE_DAP)
@ -1293,6 +1287,26 @@ CHECK_TYPE_SIZE("_Bool" SIZEOF__BOOL)
CHECK_TYPE_SIZE("size_t" SIZEOF_SIZE_T)
# Check whether to turn on or off CDF5 support.
SET(ENABLE_CDF5 AUTO CACHE STRING "AUTO")
OPTION(ENABLE_CDF5 "Enable CDF5 support" ON)
IF(SIZEOF_SIZE_T EQUAL 4)
IF(ENABLE_CDF5) # enable or auto
STRING(TOUPPER ${ENABLE_CDF5} ENABLE_CDF5)
IF(ENABLE_CDF5 AND NOT ENABLE_CDF5 STREQUAL "AUTO") # explicitly enabled
MESSAGE(FATAL_ERROR "Unable to support CDF5 feature because size_t is less than 8 bytes")
ENDIF(ENABLE_CDF5 AND NOT ENABLE_CDF5 STREQUAL "AUTO")
SET(ENABLE_CDF5 OFF) # cannot support CDF5
SET(USE_CDF5 OFF CACHE BOOL "") # cannot support CDF5
ENDIF(ENABLE_CDF5)
ELSE(SIZEOF_SIZE_T EQUAL 4)
IF(ENABLE_CDF5) # explicitly set by user or not set
SET(USE_CDF5 ON CACHE BOOL "")
ELSE(ENABLE_CDF5) # explicitly disabled by user
SET(USE_CDF5 OFF CACHE BOOL "")
ENDIF(ENABLE_CDF5)
ENDIF(SIZEOF_SIZE_T EQUAL 4)
CHECK_TYPE_SIZE("ssize_t" SIZEOF_SSIZE_T)
IF(SIZEOF_SSIZE_T)
SET(HAVE_SSIZE_T TRUE)

View File

@ -886,20 +886,22 @@ $SLEEPCMD
AC_CHECK_SIZEOF(unsigned long long)
# Check whether we want to enable CDF5 support.
AC_MSG_CHECKING([whether CDF5 support should be enabled])
AC_MSG_CHECKING([whether CDF5 support should be disabled])
AC_ARG_ENABLE([cdf5],
[AS_HELP_STRING([--enable-cdf5],
[AS_HELP_STRING([--disable-cdf5],
[build without CDF5 support.])],
[enable_cdf5=${enableval}], [enable_cdf5=auto]
)
if test "x${enable_cdf5}" = xyes && test "$ac_cv_sizeof_size_t" -lt "8" ; then
dnl unable to support CDF5, but --enable-cdf5 is explicitly set
AC_MSG_ERROR([Unable to support CDF5 feature because size_t is less than 4 bytes])
fi
if test "$ac_cv_sizeof_size_t" -lt "8" ; then
if test "x${enable_cdf5}" = xyes ; then
dnl unable to support CDF5, but --enable-cdf5 is explicitly set
AC_MSG_ERROR([Unable to support CDF5 feature because size_t is less than 8 bytes])
fi
enable_cdf5=no
else
enable_cdf5=yes
if test "x${enable_cdf5}" != xno ; then
enable_cdf5=yes
fi
fi
AC_MSG_RESULT($enable_cdf5)