2017-04-18 03:32:16 +08:00
#
# Copyright by The HDF Group.
# All rights reserved.
#
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#
2010-05-14 00:01:50 +08:00
#-----------------------------------------------------------------------------
# Include all the necessary files for macros
#-----------------------------------------------------------------------------
2014-05-15 03:50:28 +08:00
set ( HDF_PREFIX "H5" )
include ( ${ HDF_RESOURCES_EXT_DIR } /ConfigureChecks.cmake )
2016-03-31 22:02:24 +08:00
if ( HDF5_ENABLE_USING_MEMCHECKER )
2018-04-25 06:22:55 +08:00
set ( ${ HDF_PREFIX } _USING_MEMCHECKER 1 )
2017-01-11 07:09:53 +08:00
endif ( )
2010-05-14 00:01:50 +08:00
#-----------------------------------------------------------------------------
# Option for --enable-strict-format-checks
#-----------------------------------------------------------------------------
2014-03-12 05:14:57 +08:00
option ( HDF5_STRICT_FORMAT_CHECKS "Whether to perform strict file format checks" OFF )
if ( HDF5_STRICT_FORMAT_CHECKS )
2018-04-25 06:22:55 +08:00
set ( ${ HDF_PREFIX } _STRICT_FORMAT_CHECKS 1 )
2017-01-11 07:09:53 +08:00
endif ( )
2010-09-10 00:30:23 +08:00
MARK_AS_ADVANCED ( HDF5_STRICT_FORMAT_CHECKS )
2010-05-14 00:01:50 +08:00
2015-08-06 05:01:07 +08:00
# ----------------------------------------------------------------------
# Decide whether the data accuracy has higher priority during data
# conversions. If not, some hard conversions will still be prefered even
# though the data may be wrong (for example, some compilers don't
# support denormalized floating values) to maximize speed.
#
option ( HDF5_WANT_DATA_ACCURACY "IF data accuracy is guaranteed during data conversions" ON )
if ( HDF5_WANT_DATA_ACCURACY )
2018-04-25 06:22:55 +08:00
set ( ${ HDF_PREFIX } _WANT_DATA_ACCURACY 1 )
2017-01-11 07:09:53 +08:00
endif ( )
2015-08-06 05:01:07 +08:00
MARK_AS_ADVANCED ( HDF5_WANT_DATA_ACCURACY )
2010-05-14 00:01:50 +08:00
# ----------------------------------------------------------------------
# Decide whether the presence of user's exception handling functions is
# checked and data conversion exceptions are returned. This is mainly
# for the speed optimization of hard conversions. Soft conversions can
# actually benefit little.
#
2014-03-12 05:14:57 +08:00
option ( HDF5_WANT_DCONV_EXCEPTION "exception handling functions is checked during data conversions" ON )
if ( HDF5_WANT_DCONV_EXCEPTION )
2018-04-25 06:22:55 +08:00
set ( ${ HDF_PREFIX } _WANT_DCONV_EXCEPTION 1 )
2017-01-11 07:09:53 +08:00
endif ( )
2010-09-10 00:30:23 +08:00
MARK_AS_ADVANCED ( HDF5_WANT_DCONV_EXCEPTION )
2010-05-14 00:01:50 +08:00
2010-09-10 00:30:23 +08:00
# ----------------------------------------------------------------------
# Check if they would like the function stack support compiled in
#
2014-03-12 05:14:57 +08:00
option ( HDF5_ENABLE_CODESTACK "Enable the function stack tracing (for developer debugging)." OFF )
if ( HDF5_ENABLE_CODESTACK )
2018-04-25 06:22:55 +08:00
set ( ${ HDF_PREFIX } _HAVE_CODESTACK 1 )
2017-01-11 07:09:53 +08:00
endif ( )
2010-09-10 00:30:23 +08:00
MARK_AS_ADVANCED ( HDF5_ENABLE_CODESTACK )
2010-05-14 00:01:50 +08:00
2014-05-15 03:50:28 +08:00
#-----------------------------------------------------------------------------
# Are we going to use HSIZE_T
#-----------------------------------------------------------------------------
2014-03-12 05:14:57 +08:00
option ( HDF5_ENABLE_HSIZET "Enable datasets larger than memory" ON )
2014-05-15 03:50:28 +08:00
if ( HDF5_ENABLE_HSIZET )
set ( ${ HDF_PREFIX } _HAVE_LARGE_HSIZET 1 )
2017-01-11 07:09:53 +08:00
endif ( )
2010-05-14 00:01:50 +08:00
2010-10-05 05:36:27 +08:00
# so far we have no check for this
2018-04-25 06:22:55 +08:00
set ( ${ HDF_PREFIX } _HAVE_TMPFILE 1 )
2010-10-05 05:36:27 +08:00
2010-05-14 00:01:50 +08:00
# TODO --------------------------------------------------------------------------
# Should the Default Virtual File Driver be compiled?
# This is hard-coded now but option should added to match configure
#
2018-04-25 06:22:55 +08:00
set ( ${ HDF_PREFIX } _DEFAULT_VFD H5FD_SEC2 )
2014-03-12 05:14:57 +08:00
2018-04-25 06:22:55 +08:00
if ( NOT DEFINED "${HDF_PREFIX}_DEFAULT_PLUGINDIR" )
2014-03-12 05:14:57 +08:00
if ( WINDOWS )
2018-04-25 06:22:55 +08:00
set ( ${ HDF_PREFIX } _DEFAULT_PLUGINDIR "%ALLUSERSPROFILE%\\\\hdf5\\\\lib\\\\plugin" )
2017-01-11 07:09:53 +08:00
else ( )
2018-04-25 06:22:55 +08:00
set ( ${ HDF_PREFIX } _DEFAULT_PLUGINDIR "/usr/local/hdf5/lib/plugin" )
2017-01-11 07:09:53 +08:00
endif ( )
endif ( )
2014-03-12 05:14:57 +08:00
if ( WINDOWS )
2018-04-25 06:22:55 +08:00
set ( ${ HDF_PREFIX } _HAVE_WINDOWS 1 )
2010-05-14 00:01:50 +08:00
# ----------------------------------------------------------------------
# Set the flag to indicate that the machine has window style pathname,
# that is, "drive-letter:\" (e.g. "C:") or "drive-letter:/" (e.g. "C:/").
# (This flag should be _unset_ for all machines, except for Windows)
2018-04-25 06:22:55 +08:00
set ( ${ HDF_PREFIX } _HAVE_WINDOW_PATH 1 )
2017-01-11 07:09:53 +08:00
endif ( )
2014-03-12 05:14:57 +08:00
2010-10-05 05:36:27 +08:00
# ----------------------------------------------------------------------
# END of WINDOWS Hard code Values
# ----------------------------------------------------------------------
2018-04-25 06:22:55 +08:00
CHECK_FUNCTION_EXISTS ( difftime ${ HDF_PREFIX } _HAVE_DIFFTIME )
2012-06-05 01:05:02 +08:00
# Find the library containing clock_gettime()
2019-07-23 03:23:05 +08:00
if ( MINGW OR NOT WINDOWS )
2017-03-02 04:47:53 +08:00
CHECK_FUNCTION_EXISTS ( clock_gettime CLOCK_GETTIME_IN_LIBC )
CHECK_LIBRARY_EXISTS ( rt clock_gettime "" CLOCK_GETTIME_IN_LIBRT )
CHECK_LIBRARY_EXISTS ( posix4 clock_gettime "" CLOCK_GETTIME_IN_LIBPOSIX4 )
2014-03-12 05:14:57 +08:00
if ( CLOCK_GETTIME_IN_LIBC )
2018-04-25 06:22:55 +08:00
set ( ${ HDF_PREFIX } _HAVE_CLOCK_GETTIME 1 )
2014-03-12 05:14:57 +08:00
elseif ( CLOCK_GETTIME_IN_LIBRT )
2018-04-25 06:22:55 +08:00
set ( ${ HDF_PREFIX } _HAVE_CLOCK_GETTIME 1 )
2014-03-12 05:14:57 +08:00
list ( APPEND LINK_LIBS rt )
elseif ( CLOCK_GETTIME_IN_LIBPOSIX4 )
2018-04-25 06:22:55 +08:00
set ( ${ HDF_PREFIX } _HAVE_CLOCK_GETTIME 1 )
2014-03-12 05:14:57 +08:00
list ( APPEND LINK_LIBS posix4 )
2017-01-11 07:09:53 +08:00
endif ( )
endif ( )
2012-06-05 01:05:02 +08:00
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Check if Direct I/O driver works
#-----------------------------------------------------------------------------
2014-03-12 05:14:57 +08:00
if ( NOT WINDOWS )
2015-09-11 11:03:41 +08:00
option ( HDF5_ENABLE_DIRECT_VFD "Build the Direct I/O Virtual File Driver" OFF )
2014-03-12 05:14:57 +08:00
if ( HDF5_ENABLE_DIRECT_VFD )
set ( msg "Performing TEST_DIRECT_VFD_WORKS" )
set ( MACRO_CHECK_FUNCTION_DEFINITIONS "-DTEST_DIRECT_VFD_WORKS -D_GNU_SOURCE ${CMAKE_REQUIRED_FLAGS}" )
2012-06-05 01:05:02 +08:00
TRY_RUN ( TEST_DIRECT_VFD_WORKS_RUN TEST_DIRECT_VFD_WORKS_COMPILE
2014-05-15 03:50:28 +08:00
$ { C M A K E _ B I N A R Y _ D I R }
$ { H D F _ R E S O U R C E S _ E X T _ D I R } / H D F T e s t s . c
2012-06-05 01:05:02 +08:00
C M A K E _ F L A G S - D C O M P I L E _ D E F I N I T I O N S : S T R I N G = $ { M A C R O _ C H E C K _ F U N C T I O N _ D E F I N I T I O N S }
O U T P U T _ V A R I A B L E O U T P U T
)
2014-03-12 05:14:57 +08:00
if ( TEST_DIRECT_VFD_WORKS_COMPILE )
2017-01-11 07:09:53 +08:00
if ( TEST_DIRECT_VFD_WORKS_RUN MATCHES 0 )
2014-05-15 03:50:28 +08:00
HDF_FUNCTION_TEST ( HAVE_DIRECT )
2014-03-12 05:14:57 +08:00
set ( CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE" )
add_definitions ( "-D_GNU_SOURCE" )
2017-01-11 07:09:53 +08:00
else ( )
2014-03-12 05:14:57 +08:00
set ( TEST_DIRECT_VFD_WORKS "" CACHE INTERNAL ${ msg } )
message ( STATUS "${msg}... no" )
2014-03-19 00:21:46 +08:00
file ( APPEND ${ CMAKE_BINARY_DIR } /CMakeFiles/CMakeError.log
2012-06-05 01:05:02 +08:00
" T e s t T E S T _ D I R E C T _ V F D _ W O R K S R u n f a i l e d w i t h t h e f o l l o w i n g o u t p u t a n d e x i t c o d e : \ n $ { O U T P U T } \ n "
)
2017-01-11 07:09:53 +08:00
endif ( )
2017-03-02 04:47:53 +08:00
else ( )
2014-03-12 05:14:57 +08:00
set ( TEST_DIRECT_VFD_WORKS "" CACHE INTERNAL ${ msg } )
message ( STATUS "${msg}... no" )
2014-03-19 00:21:46 +08:00
file ( APPEND ${ CMAKE_BINARY_DIR } /CMakeFiles/CMakeError.log
2012-06-05 01:05:02 +08:00
" T e s t T E S T _ D I R E C T _ V F D _ W O R K S C o m p i l e f a i l e d w i t h t h e f o l l o w i n g o u t p u t : \ n $ { O U T P U T } \ n "
)
2017-01-11 07:09:53 +08:00
endif ( )
endif ( )
endif ( )
2010-05-14 00:01:50 +08:00
2019-07-26 00:36:37 +08:00
#-----------------------------------------------------------------------------
2019-07-27 00:56:03 +08:00
# Check if ROS3 driver can be built
2019-07-26 00:36:37 +08:00
#-----------------------------------------------------------------------------
option ( HDF5_ENABLE_ROS3_VFD "Build the ROS3 Virtual File Driver" OFF )
if ( HDF5_ENABLE_ROS3_VFD )
find_package ( CURL REQUIRED )
find_package ( OpenSSL REQUIRED )
if ( ${ CURL_FOUND } AND ${ OPENSSL_FOUND } )
set ( ${ HDF_PREFIX } _HAVE_ROS3_VFD 1 )
list ( APPEND LINK_LIBS ${ CURL_LIBRARIES } ${ OPENSSL_LIBRARIES } )
else ( )
message ( STATUS "The Read-Only S3 VFD was requested but cannot be built.\nPlease check that openssl and cURL are available on your\nsystem, and/or re-configure without option HDF5_ENABLE_ROS3_VFD." )
endif ( )
endif ( )
2015-08-11 22:35:30 +08:00
#-----------------------------------------------------------------------------
# Check if C has __float128 extension
#-----------------------------------------------------------------------------
2018-07-31 05:31:39 +08:00
CHECK_TYPE_SIZE ( "__float128" ${ HDF_PREFIX } _SIZEOF___FLOAT128 )
if ( ${ ${HDF_PREFIX } _SIZEOF___FLOAT128} )
2018-04-25 06:22:55 +08:00
set ( ${ HDF_PREFIX } _HAVE_FLOAT128 1 )
2017-01-11 07:09:53 +08:00
else ( )
2018-04-25 06:22:55 +08:00
set ( ${ HDF_PREFIX } _HAVE_FLOAT128 0 )
2018-07-31 05:31:39 +08:00
set ( ${ HDF_PREFIX } _SIZEOF___FLOAT128 0 )
2017-03-02 04:47:53 +08:00
endif ( )
2010-05-14 00:01:50 +08:00
2018-07-31 05:31:39 +08:00
CHECK_TYPE_SIZE ( "_Quad" ${ HDF_PREFIX } _SIZEOF__QUAD )
2018-07-31 06:10:00 +08:00
if ( NOT ${ ${HDF_PREFIX } _SIZEOF__QUAD} )
set ( ${ HDF_PREFIX } _SIZEOF__QUAD 0 )
endif ( )
2018-07-31 05:31:39 +08:00
2010-05-14 00:01:50 +08:00
#-----------------------------------------------------------------------------
# Macro to determine the various conversion capabilities
#-----------------------------------------------------------------------------
2017-03-02 04:47:53 +08:00
macro ( H5ConversionTests TEST msg )
2018-01-31 06:22:18 +08:00
if ( NOT DEFINED ${ TEST } )
2014-03-12 05:14:57 +08:00
# message (STATUS "===> ${TEST}")
2010-05-14 00:01:50 +08:00
TRY_RUN ( ${ TEST } _RUN ${ TEST } _COMPILE
2014-05-15 03:50:28 +08:00
$ { C M A K E _ B I N A R Y _ D I R }
$ { H D F _ R E S O U R C E S _ D I R } / C o n v e r s i o n T e s t s . c
2010-05-14 00:01:50 +08:00
C M A K E _ F L A G S - D C O M P I L E _ D E F I N I T I O N S : S T R I N G = - D $ { T E S T } _ T E S T
O U T P U T _ V A R I A B L E O U T P U T
)
2014-03-12 05:14:57 +08:00
if ( ${ TEST } _COMPILE )
2017-01-11 07:09:53 +08:00
if ( ${ TEST } _RUN MATCHES 0 )
2014-03-12 05:14:57 +08:00
set ( ${ TEST } 1 CACHE INTERNAL ${ msg } )
message ( STATUS "${msg}... yes" )
2017-01-11 07:09:53 +08:00
else ( )
2014-03-12 05:14:57 +08:00
set ( ${ TEST } "" CACHE INTERNAL ${ msg } )
message ( STATUS "${msg}... no" )
2014-03-19 00:21:46 +08:00
file ( APPEND ${ CMAKE_BINARY_DIR } /CMakeFiles/CMakeError.log
2010-05-14 00:01:50 +08:00
" T e s t $ { T E S T } R u n f a i l e d w i t h t h e f o l l o w i n g o u t p u t a n d e x i t c o d e : \ n $ { O U T P U T } \ n "
)
2017-01-11 07:09:53 +08:00
endif ( )
else ( )
2014-03-12 05:14:57 +08:00
set ( ${ TEST } "" CACHE INTERNAL ${ msg } )
message ( STATUS "${msg}... no" )
2014-03-19 00:21:46 +08:00
file ( APPEND ${ CMAKE_BINARY_DIR } /CMakeFiles/CMakeError.log
2010-05-14 00:01:50 +08:00
" T e s t $ { T E S T } C o m p i l e f a i l e d w i t h t h e f o l l o w i n g o u t p u t : \ n $ { O U T P U T } \ n "
)
2017-01-11 07:09:53 +08:00
endif ( )
2010-05-14 00:01:50 +08:00
2017-01-11 07:09:53 +08:00
endif ( )
2017-03-02 04:47:53 +08:00
endmacro ( )
2010-05-14 00:01:50 +08:00
#-----------------------------------------------------------------------------
# Check various conversion capabilities
#-----------------------------------------------------------------------------
# ----------------------------------------------------------------------
2012-06-05 01:05:02 +08:00
# Set the flag to indicate that the machine is using a special algorithm to convert
2017-01-11 07:09:53 +08:00
# 'long double' to '(unsigned) long' values. (This flag should only be set for
# the IBM Power6 Linux. When the bit sequence of long double is
# 0x4351ccf385ebc8a0bfcc2a3c3d855620, the converted value of (unsigned)long
2012-06-05 01:05:02 +08:00
# is 0x004733ce17af227f, not the same as the library's conversion to 0x004733ce17af2282.
# The machine's conversion gets the correct value. We define the macro and disable
# this kind of test until we figure out what algorithm they use.
#
2018-04-25 06:22:55 +08:00
H5ConversionTests ( ${ HDF_PREFIX } _LDOUBLE_TO_LONG_SPECIAL "Checking IF your system converts long double to (unsigned) long values with special algorithm" )
2012-06-05 01:05:02 +08:00
# ----------------------------------------------------------------------
# Set the flag to indicate that the machine is using a special algorithm
2017-01-11 07:09:53 +08:00
# to convert some values of '(unsigned) long' to 'long double' values.
# (This flag should be off for all machines, except for IBM Power6 Linux,
# when the bit sequences are 003fff..., 007fff..., 00ffff..., 01ffff...,
# ..., 7fffff..., the compiler uses a unknown algorithm. We define a
2012-06-05 01:05:02 +08:00
# macro and skip the test for now until we know about the algorithm.
#
2018-04-25 06:22:55 +08:00
H5ConversionTests ( ${ HDF_PREFIX } _LONG_TO_LDOUBLE_SPECIAL "Checking IF your system can convert (unsigned) long to long double values with special algorithm" )
2012-06-05 01:05:02 +08:00
# ----------------------------------------------------------------------
2015-08-06 05:01:07 +08:00
# Set the flag to indicate that the machine can accurately convert
# 'long double' to '(unsigned) long long' values. (This flag should be set for
# all machines, except for Mac OS 10.4 and SGI IRIX64 6.5. When the bit sequence
# of long double is 0x4351ccf385ebc8a0bfcc2a3c..., the values of (unsigned)long long
# start to go wrong on these two machines. Adjusting it higher to
# 0x4351ccf385ebc8a0dfcc... or 0x4351ccf385ebc8a0ffcc... will make the converted
# values wildly wrong. This test detects this wrong behavior and disable the test.
#
2018-04-25 06:22:55 +08:00
H5ConversionTests ( ${ HDF_PREFIX } _LDOUBLE_TO_LLONG_ACCURATE "Checking IF correctly converting long double to (unsigned) long long values" )
2015-08-06 05:01:07 +08:00
# ----------------------------------------------------------------------
# Set the flag to indicate that the machine can accurately convert
# '(unsigned) long long' to 'long double' values. (This flag should be set for
# all machines, except for Mac OS 10.4, when the bit sequences are 003fff...,
# 007fff..., 00ffff..., 01ffff..., ..., 7fffff..., the converted values are twice
# as big as they should be.
#
2018-04-25 06:22:55 +08:00
H5ConversionTests ( ${ HDF_PREFIX } _LLONG_TO_LDOUBLE_CORRECT "Checking IF correctly converting (unsigned) long long to long double values" )
2015-08-06 05:01:07 +08:00
# ----------------------------------------------------------------------
2019-01-08 10:28:37 +08:00
# Set the flag to indicate that the machine can accurately convert
# some long double values
#
H5ConversionTests ( ${ HDF_PREFIX } _DISABLE_SOME_LDOUBLE_CONV "Checking IF the cpu is power9 and cannot correctly converting long double values" )
# ----------------------------------------------------------------------
2012-06-05 01:05:02 +08:00
# Check if pointer alignments are enforced
#
2018-04-25 06:22:55 +08:00
H5ConversionTests ( ${ HDF_PREFIX } _NO_ALIGNMENT_RESTRICTIONS "Checking IF alignment restrictions are strictly enforced" )