| 1 |
# |
| 2 |
# Copyright by The HDF Group. |
| 3 |
# All rights reserved. |
| 4 |
# |
| 5 |
# This file is part of HDF5. The full HDF5 copyright notice, including |
| 6 |
# terms governing use, modification, and redistribution, is contained in |
| 7 |
# the COPYING file, which can be found at the root of the source code |
| 8 |
# distribution tree, or in https://www.hdfgroup.org/licenses. |
| 9 |
# If you do not have access to either file, you may request a copy from |
| 10 |
# [email protected]. |
| 11 |
# |
| 12 |
#----------------------------------------------------------------------------- |
| 13 |
# Include all the necessary files for macros |
| 14 |
#----------------------------------------------------------------------------- |
| 15 |
set (HDF_PREFIX "H5") |
| 16 |
include (${HDF_RESOURCES_EXT_DIR}/ConfigureChecks.cmake) |
| 17 |
|
| 18 |
if (HDF5_ENABLE_USING_MEMCHECKER) |
| 19 |
set (${HDF_PREFIX}_USING_MEMCHECKER 1) |
| 20 |
endif () |
| 21 |
|
| 22 |
#----------------------------------------------------------------------------- |
| 23 |
# Option for --enable-strict-format-checks |
| 24 |
#----------------------------------------------------------------------------- |
| 25 |
if (FALSE) # XXX(kitware): Hardcode settings. |
| 26 |
option (HDF5_STRICT_FORMAT_CHECKS "Whether to perform strict file format checks" OFF) |
| 27 |
else () |
| 28 |
set(HDF5_STRICT_FORMAT_CHECKS OFF) |
| 29 |
endif () |
| 30 |
if (HDF5_STRICT_FORMAT_CHECKS) |
| 31 |
set (${HDF_PREFIX}_STRICT_FORMAT_CHECKS 1) |
| 32 |
endif () |
| 33 |
MARK_AS_ADVANCED (HDF5_STRICT_FORMAT_CHECKS) |
| 34 |
|
| 35 |
#----------------------------------------------------------------------------- |
| 36 |
# Option for --enable-threadsafe |
| 37 |
#----------------------------------------------------------------------------- |
| 38 |
# Recursive RW locks are not supported on Windows (yet) |
| 39 |
if (NOT WINDOWS) |
| 40 |
if (FALSE) # XXX(kitware): Hardcode settings. |
| 41 |
option (HDF5_USE_RECURSIVE_RW_LOCKS "Whether to use recursive RW locks for thread-safety" OFF) |
| 42 |
else () |
| 43 |
set(HDF5_USE_RECURSIVE_RW_LOCKS OFF) |
| 44 |
endif () |
| 45 |
if (HDF5_USE_RECURSIVE_RW_LOCKS) |
| 46 |
set (${HDF_PREFIX}_USE_RECURSIVE_RW_LOCKS 1) |
| 47 |
endif () |
| 48 |
MARK_AS_ADVANCED (HDF5_USE_RECURSIVE_RW_LOCKS) |
| 49 |
endif () |
| 50 |
|
| 51 |
# ---------------------------------------------------------------------- |
| 52 |
# Decide whether the data accuracy has higher priority during data |
| 53 |
# conversions. If not, some hard conversions will still be prefered even |
| 54 |
# though the data may be wrong (for example, some compilers don't |
| 55 |
# support denormalized floating values) to maximize speed. |
| 56 |
#----------------------------------------------------------------------------- |
| 57 |
if (FALSE) # XXX(kitware): Hardcode settings. |
| 58 |
option (HDF5_WANT_DATA_ACCURACY "IF data accuracy is guaranteed during data conversions" ON) |
| 59 |
else () |
| 60 |
set(HDF5_WANT_DATA_ACCURACY ON) |
| 61 |
endif () |
| 62 |
if (HDF5_WANT_DATA_ACCURACY) |
| 63 |
set (${HDF_PREFIX}_WANT_DATA_ACCURACY 1) |
| 64 |
endif () |
| 65 |
MARK_AS_ADVANCED (HDF5_WANT_DATA_ACCURACY) |
| 66 |
|
| 67 |
# ---------------------------------------------------------------------- |
| 68 |
# Decide whether the presence of user's exception handling functions is |
| 69 |
# checked and data conversion exceptions are returned. This is mainly |
| 70 |
# for the speed optimization of hard conversions. Soft conversions can |
| 71 |
# actually benefit little. |
| 72 |
#----------------------------------------------------------------------------- |
| 73 |
if (FALSE) # XXX(kitware): Hardcode settings. |
| 74 |
option (HDF5_WANT_DCONV_EXCEPTION "exception handling functions is checked during data conversions" ON) |
| 75 |
else () |
| 76 |
set(HDF5_WANT_DCONV_EXCEPTION ON) |
| 77 |
endif () |
| 78 |
if (HDF5_WANT_DCONV_EXCEPTION) |
| 79 |
set (${HDF_PREFIX}_WANT_DCONV_EXCEPTION 1) |
| 80 |
endif () |
| 81 |
MARK_AS_ADVANCED (HDF5_WANT_DCONV_EXCEPTION) |
| 82 |
|
| 83 |
# ---------------------------------------------------------------------- |
| 84 |
# Check if they would like the function stack support compiled in |
| 85 |
#----------------------------------------------------------------------------- |
| 86 |
if (FALSE) # XXX(kitware): Hardcode settings. |
| 87 |
option (HDF5_ENABLE_CODESTACK "Enable the function stack tracing (for developer debugging)." OFF) |
| 88 |
else () |
| 89 |
set(HDF5_ENABLE_CODESTACK OFF) |
| 90 |
endif () |
| 91 |
if (HDF5_ENABLE_CODESTACK) |
| 92 |
set (${HDF_PREFIX}_HAVE_CODESTACK 1) |
| 93 |
endif () |
| 94 |
MARK_AS_ADVANCED (HDF5_ENABLE_CODESTACK) |
| 95 |
|
| 96 |
# ---------------------------------------------------------------------- |
| 97 |
# Check if they would like to use file locking by default |
| 98 |
#----------------------------------------------------------------------------- |
| 99 |
if (FALSE) # XXX(kitware): Hardcode settings. |
| 100 |
option (HDF5_USE_FILE_LOCKING "Use file locking by default (mainly for SWMR)" ON) |
| 101 |
else () |
| 102 |
set(HDF5_USE_FILE_LOCKING ON) |
| 103 |
endif () |
| 104 |
if (HDF5_USE_FILE_LOCKING) |
| 105 |
set (${HDF_PREFIX}_USE_FILE_LOCKING 1) |
| 106 |
endif () |
| 107 |
|
| 108 |
# ---------------------------------------------------------------------- |
| 109 |
# Check if they would like to ignore file locks when disabled on a file system |
| 110 |
#----------------------------------------------------------------------------- |
| 111 |
if (FALSE) # XXX(kitware): Hardcode settings. |
| 112 |
option (HDF5_IGNORE_DISABLED_FILE_LOCKS "Ignore file locks when disabled on file system" ON) |
| 113 |
else () |
| 114 |
set(HDF5_IGNORE_DISABLED_FILE_LOCKS ON) |
| 115 |
endif () |
| 116 |
if (HDF5_IGNORE_DISABLED_FILE_LOCKS) |
| 117 |
set (${HDF_PREFIX}_IGNORE_DISABLED_FILE_LOCKS 1) |
| 118 |
endif () |
| 119 |
|
| 120 |
# Set the libhdf5.settings file variable |
| 121 |
if (HDF5_IGNORE_DISABLED_FILE_LOCKS AND HDF5_USE_FILE_LOCKING) |
| 122 |
set (HDF5_FILE_LOCKING_SETTING "best-effort") |
| 123 |
elseif (HDF5_IGNORE_DISABLED_FILE_LOCKS) |
| 124 |
set (HDF5_FILE_LOCKING_SETTING "yes") |
| 125 |
else () |
| 126 |
set (HDF5_FILE_LOCKING_SETTING "no") |
| 127 |
endif () |
| 128 |
|
| 129 |
#----------------------------------------------------------------------------- |
| 130 |
# Are we going to use HSIZE_T |
| 131 |
#----------------------------------------------------------------------------- |
| 132 |
if (FALSE) # XXX(kitware): Hardcode settings. |
| 133 |
option (HDF5_ENABLE_HSIZET "Enable datasets larger than memory" ON) |
| 134 |
else () |
| 135 |
set(HDF5_ENABLE_HSIZET OFF) |
| 136 |
endif () |
| 137 |
if (HDF5_ENABLE_HSIZET) |
| 138 |
set (${HDF_PREFIX}_HAVE_LARGE_HSIZET 1) |
| 139 |
endif () |
| 140 |
|
| 141 |
# so far we have no check for this |
| 142 |
set (${HDF_PREFIX}_HAVE_TMPFILE 1) |
| 143 |
|
| 144 |
# TODO -------------------------------------------------------------------------- |
| 145 |
# Should the Default Virtual File Driver be compiled? |
| 146 |
# This is hard-coded now but option should added to match configure |
| 147 |
#----------------------------------------------------------------------------- |
| 148 |
set (${HDF_PREFIX}_DEFAULT_VFD H5FD_SEC2) |
| 149 |
|
| 150 |
if (NOT DEFINED "${HDF_PREFIX}_DEFAULT_PLUGINDIR") |
| 151 |
if (WINDOWS) |
| 152 |
set (${HDF_PREFIX}_DEFAULT_PLUGINDIR "%ALLUSERSPROFILE%\\\\hdf5\\\\lib\\\\plugin") |
| 153 |
else () |
| 154 |
set (${HDF_PREFIX}_DEFAULT_PLUGINDIR "/usr/local/hdf5/lib/plugin") |
| 155 |
endif () |
| 156 |
endif () |
| 157 |
|
| 158 |
if (WINDOWS) |
| 159 |
set (${HDF_PREFIX}_HAVE_WINDOWS 1) |
| 160 |
# ---------------------------------------------------------------------- |
| 161 |
# Set the flag to indicate that the machine has window style pathname, |
| 162 |
# that is, "drive-letter:\" (e.g. "C:") or "drive-letter:/" (e.g. "C:/"). |
| 163 |
# (This flag should be _unset_ for all machines, except for Windows) |
| 164 |
#----------------------------------------------------------------------- |
| 165 |
set (${HDF_PREFIX}_HAVE_WINDOW_PATH 1) |
| 166 |
endif () |
| 167 |
|
| 168 |
# ---------------------------------------------------------------------- |
| 169 |
# END of WINDOWS Hard code Values |
| 170 |
# ---------------------------------------------------------------------- |
| 171 |
|
| 172 |
# Find the library containing clock_gettime() |
| 173 |
if (MINGW OR NOT WINDOWS) |
| 174 |
CHECK_FUNCTION_EXISTS (clock_gettime CLOCK_GETTIME_IN_LIBC) |
| 175 |
CHECK_LIBRARY_EXISTS (rt clock_gettime "" CLOCK_GETTIME_IN_LIBRT) |
| 176 |
CHECK_LIBRARY_EXISTS (posix4 clock_gettime "" CLOCK_GETTIME_IN_LIBPOSIX4) |
| 177 |
if (CLOCK_GETTIME_IN_LIBC) |
| 178 |
set (${HDF_PREFIX}_HAVE_CLOCK_GETTIME 1) |
| 179 |
elseif (CLOCK_GETTIME_IN_LIBRT) |
| 180 |
set (${HDF_PREFIX}_HAVE_CLOCK_GETTIME 1) |
| 181 |
list (APPEND LINK_LIBS rt) |
| 182 |
elseif (CLOCK_GETTIME_IN_LIBPOSIX4) |
| 183 |
set (${HDF_PREFIX}_HAVE_CLOCK_GETTIME 1) |
| 184 |
list (APPEND LINK_LIBS posix4) |
| 185 |
endif () |
| 186 |
endif () |
| 187 |
#----------------------------------------------------------------------------- |
| 188 |
|
| 189 |
#----------------------------------------------------------------------------- |
| 190 |
# Check if Direct I/O driver works |
| 191 |
#----------------------------------------------------------------------------- |
| 192 |
if (NOT WINDOWS) |
| 193 |
if (FALSE) # XXX(kitware): Hardcode settings. |
| 194 |
option (HDF5_ENABLE_DIRECT_VFD "Build the Direct I/O Virtual File Driver" OFF) |
| 195 |
else () |
| 196 |
set(HDF5_ENABLE_DIRECT_VFD OFF) |
| 197 |
endif () |
| 198 |
if (HDF5_ENABLE_DIRECT_VFD) |
| 199 |
set (msg "Performing TEST_DIRECT_VFD_WORKS") |
| 200 |
set (MACRO_CHECK_FUNCTION_DEFINITIONS "-DTEST_DIRECT_VFD_WORKS -D_GNU_SOURCE ${CMAKE_REQUIRED_FLAGS}") |
| 201 |
TRY_RUN (TEST_DIRECT_VFD_WORKS_RUN TEST_DIRECT_VFD_WORKS_COMPILE |
| 202 |
${CMAKE_BINARY_DIR} |
| 203 |
${HDF_RESOURCES_EXT_DIR}/HDFTests.c |
| 204 |
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} |
| 205 |
OUTPUT_VARIABLE OUTPUT |
| 206 |
) |
| 207 |
if (TEST_DIRECT_VFD_WORKS_COMPILE) |
| 208 |
if (TEST_DIRECT_VFD_WORKS_RUN EQUAL "0") |
| 209 |
HDF_FUNCTION_TEST (HAVE_DIRECT) |
| 210 |
set (CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE") |
| 211 |
add_definitions ("-D_GNU_SOURCE") |
| 212 |
else () |
| 213 |
set (TEST_DIRECT_VFD_WORKS "" CACHE INTERNAL ${msg}) |
| 214 |
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") |
| 215 |
message (VERBOSE "${msg}... no") |
| 216 |
endif () |
| 217 |
file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log |
| 218 |
"Test TEST_DIRECT_VFD_WORKS Run failed with the following output and exit code:\n ${OUTPUT}\n" |
| 219 |
) |
| 220 |
endif () |
| 221 |
else () |
| 222 |
set (TEST_DIRECT_VFD_WORKS "" CACHE INTERNAL ${msg}) |
| 223 |
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") |
| 224 |
message (VERBOSE "${msg}... no") |
| 225 |
endif () |
| 226 |
file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log |
| 227 |
"Test TEST_DIRECT_VFD_WORKS Compile failed with the following output:\n ${OUTPUT}\n" |
| 228 |
) |
| 229 |
endif () |
| 230 |
endif () |
| 231 |
endif () |
| 232 |
|
| 233 |
#----------------------------------------------------------------------------- |
| 234 |
# Check if ROS3 driver can be built |
| 235 |
#----------------------------------------------------------------------------- |
| 236 |
if (FALSE) # XXX(kitware): Hardcode settings. |
| 237 |
option (HDF5_ENABLE_ROS3_VFD "Build the ROS3 Virtual File Driver" OFF) |
| 238 |
else () |
| 239 |
set(HDF5_ENABLE_ROS3_VFD OFF) |
| 240 |
endif () |
| 241 |
if (HDF5_ENABLE_ROS3_VFD) |
| 242 |
find_package(CURL REQUIRED) |
| 243 |
find_package(OpenSSL REQUIRED) |
| 244 |
if (${CURL_FOUND} AND ${OPENSSL_FOUND}) |
| 245 |
set (${HDF_PREFIX}_HAVE_ROS3_VFD 1) |
| 246 |
list (APPEND LINK_LIBS ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES}) |
| 247 |
INCLUDE_DIRECTORIES (${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}) |
| 248 |
else () |
| 249 |
message (WARNING "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.") |
| 250 |
endif () |
| 251 |
endif () |
| 252 |
|
| 253 |
# ---------------------------------------------------------------------- |
| 254 |
# Check whether we can build the Mirror VFD |
| 255 |
# Header-check flags set in config/cmake_ext_mod/ConfigureChecks.cmake |
| 256 |
# ---------------------------------------------------------------------- |
| 257 |
if (FALSE) # XXX(kitware): Hardcode settings. |
| 258 |
option (HDF5_ENABLE_MIRROR_VFD "Build the Mirror Virtual File Driver" OFF) |
| 259 |
else () |
| 260 |
set(HDF5_ENABLE_MIRROR_VFD OFF) |
| 261 |
endif () |
| 262 |
if (H5FD_ENABLE_MIRROR_VFD) |
| 263 |
if ( ${HDF_PREFIX}_HAVE_NETINET_IN_H AND |
| 264 |
${HDF_PREFIX}_HAVE_NETDB_H AND |
| 265 |
${HDF_PREFIX}_HAVE_ARPA_INET_H AND |
| 266 |
${HDF_PREFIX}_HAVE_SYS_SOCKET_H AND |
| 267 |
${HDF_PREFIX}_HAVE_FORK) |
| 268 |
set (${HDF_PREFIX}_HAVE_MIRROR_VFD 1) |
| 269 |
else() |
| 270 |
message(WARNING "The socket-based Mirror VFD was requested but cannot be built. System prerequisites are not met.") |
| 271 |
endif() |
| 272 |
endif() |
| 273 |
|
| 274 |
#----------------------------------------------------------------------------- |
| 275 |
# Check if C has __float128 extension |
| 276 |
#----------------------------------------------------------------------------- |
| 277 |
|
| 278 |
HDF_CHECK_TYPE_SIZE(__float128 _SIZEOF___FLOAT128) |
| 279 |
if (${_SIZEOF___FLOAT128}) |
| 280 |
set (${HDF_PREFIX}_HAVE_FLOAT128 1) |
| 281 |
set (${HDF_PREFIX}_SIZEOF___FLOAT128 ${_SIZEOF___FLOAT128}) |
| 282 |
else () |
| 283 |
set (${HDF_PREFIX}_HAVE_FLOAT128 0) |
| 284 |
set (${HDF_PREFIX}_SIZEOF___FLOAT128 0) |
| 285 |
endif () |
| 286 |
|
| 287 |
HDF_CHECK_TYPE_SIZE(_Quad _SIZEOF__QUAD) |
| 288 |
if (NOT ${_SIZEOF__QUAD}) |
| 289 |
set (${HDF_PREFIX}_SIZEOF__QUAD 0) |
| 290 |
else () |
| 291 |
set (${HDF_PREFIX}_SIZEOF__QUAD ${_SIZEOF__QUAD}) |
| 292 |
endif () |
| 293 |
|
| 294 |
#----------------------------------------------------------------------------- |
| 295 |
# The provided CMake C macros don't provide a general compile/run function |
| 296 |
# so this one is used. |
| 297 |
#----------------------------------------------------------------------------- |
| 298 |
set (RUN_OUTPUT_PATH_DEFAULT ${CMAKE_BINARY_DIR}) |
| 299 |
macro (C_RUN FUNCTION_NAME SOURCE_CODE RETURN_VAR RETURN_OUTPUT_VAR) |
| 300 |
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") |
| 301 |
message (VERBOSE "Detecting C ${FUNCTION_NAME}") |
| 302 |
endif () |
| 303 |
file (WRITE |
| 304 |
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler1.c |
| 305 |
${SOURCE_CODE} |
| 306 |
) |
| 307 |
TRY_RUN (RUN_RESULT_VAR COMPILE_RESULT_VAR |
| 308 |
${CMAKE_BINARY_DIR} |
| 309 |
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler1.c |
| 310 |
COMPILE_DEFINITIONS "-D_SIZEOF___FLOAT128=${H5_SIZEOF___FLOAT128};-D_HAVE_QUADMATH_H=${H5_HAVE_QUADMATH_H}" |
| 311 |
COMPILE_OUTPUT_VARIABLE COMPILEOUT |
| 312 |
RUN_OUTPUT_VARIABLE OUTPUT_VAR |
| 313 |
) |
| 314 |
#[[ ITK Remove this variable that is never used |
| 315 |
set (${RETURN_OUTPUT_VAR} ${OUTPUT_VAR}) |
| 316 |
# ITK ]] |
| 317 |
|
| 318 |
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") |
| 319 |
message (VERBOSE "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") |
| 320 |
message (VERBOSE "Test COMPILE_RESULT_VAR ${COMPILE_RESULT_VAR} ") |
| 321 |
message (VERBOSE "Test COMPILE_OUTPUT ${COMPILEOUT} ") |
| 322 |
message (VERBOSE "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") |
| 323 |
message (VERBOSE "Test RUN_RESULT_VAR ${RUN_RESULT_VAR} ") |
| 324 |
message (VERBOSE "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") |
| 325 |
endif () |
| 326 |
|
| 327 |
if (COMPILE_RESULT_VAR) |
| 328 |
if (RUN_RESULT_VAR EQUAL "0") |
| 329 |
#[[ITK -- start Lookingin into an upstream PR to remove this problematic code |
| 330 |
set (${RETURN_VAR} 1 CACHE INTERNAL "Have C function ${FUNCTION_NAME}") |
| 331 |
# ITK --stop ]] |
| 332 |
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") |
| 333 |
message (VERBOSE "Testing C ${FUNCTION_NAME} - OK") |
| 334 |
endif () |
| 335 |
file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log |
| 336 |
"Determining if the C ${FUNCTION_NAME} exists passed with the following output:\n" |
| 337 |
"${OUTPUT_VAR}\n\n" |
| 338 |
) |
| 339 |
else () |
| 340 |
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") |
| 341 |
message (VERBOSE "Testing C ${FUNCTION_NAME} - Fail") |
| 342 |
endif () |
| 343 |
#[[ITK -- start Lookingin into an upstream PR to remove this problematic code |
| 344 |
set (${RETURN_VAR} 0 CACHE INTERNAL "Have C function ${FUNCTION_NAME}") |
| 345 |
# ITK --stop ]] |
| 346 |
file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log |
| 347 |
"Determining if the C ${FUNCTION_NAME} exists failed with the following output:\n" |
| 348 |
"${OUTPUT_VAR}\n\n") |
| 349 |
endif () |
| 350 |
else () |
| 351 |
message (FATAL_ERROR "Compilation of C ${FUNCTION_NAME} - Failed") |
| 352 |
endif () |
| 353 |
endmacro () |
| 354 |
|
| 355 |
set (PROG_SRC |
| 356 |
" |
| 357 |
#include <float.h>\n\ |
| 358 |
#include <stdio.h>\n\ |
| 359 |
#define CHECK_FLOAT128 _SIZEOF___FLOAT128\n\ |
| 360 |
#if CHECK_FLOAT128!=0\n\ |
| 361 |
#if _HAVE_QUADMATH_H!=0\n\ |
| 362 |
#include <quadmath.h>\n\ |
| 363 |
#endif\n\ |
| 364 |
#ifdef FLT128_DIG\n\ |
| 365 |
#define C_FLT128_DIG FLT128_DIG\n\ |
| 366 |
#else\n\ |
| 367 |
#define C_FLT128_DIG 0\n\ |
| 368 |
#endif\n\ |
| 369 |
#else\n\ |
| 370 |
#define C_FLT128_DIG 0\n\ |
| 371 |
#endif\n\ |
| 372 |
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n\ |
| 373 |
#define C_LDBL_DIG DECIMAL_DIG\n\ |
| 374 |
#else\n\ |
| 375 |
#define C_LDBL_DIG LDBL_DIG\n\ |
| 376 |
#endif\n\nint main() {\nprintf(\"\\%d\\\;\\%d\\\;\", C_LDBL_DIG, C_FLT128_DIG)\\\;\n\nreturn 0\\\;\n}\n |
| 377 |
" |
| 378 |
) |
| 379 |
|
| 380 |
C_RUN ("maximum decimal precision for C" ${PROG_SRC} PROG_RES PROG_OUTPUT4) |
| 381 |
#[[ ITK -- start |
| 382 |
message (STATUS "Testing maximum decimal precision for C - ${PROG_OUTPUT4}") |
| 383 |
# ITK -- stop ]] |
| 384 |
|
| 385 |
# dnl The output from the above program will be: |
| 386 |
# dnl -- long double decimal precision -- __float128 decimal precision |
| 387 |
|
| 388 |
list (GET PROG_OUTPUT4 0 H5_LDBL_DIG) |
| 389 |
list (GET PROG_OUTPUT4 1 H5_FLT128_DIG) |
| 390 |
|
| 391 |
if (${HDF_PREFIX}_SIZEOF___FLOAT128 EQUAL "0" OR FLT128_DIG EQUAL "0") |
| 392 |
set (${HDF_PREFIX}_HAVE_FLOAT128 0) |
| 393 |
set (${HDF_PREFIX}_SIZEOF___FLOAT128 0) |
| 394 |
set (_PAC_C_MAX_REAL_PRECISION ${H5_LDBL_DIG}) |
| 395 |
else () |
| 396 |
set (_PAC_C_MAX_REAL_PRECISION ${H5_FLT128_DIG}) |
| 397 |
endif () |
| 398 |
if (NOT ${_PAC_C_MAX_REAL_PRECISION}) |
| 399 |
set (${HDF_PREFIX}_PAC_C_MAX_REAL_PRECISION 0) |
| 400 |
else () |
| 401 |
set (${HDF_PREFIX}_PAC_C_MAX_REAL_PRECISION ${_PAC_C_MAX_REAL_PRECISION}) |
| 402 |
endif () |
| 403 |
#[[ ITK -- start |
| 404 |
message (STATUS "maximum decimal precision for C var - ${${HDF_PREFIX}_PAC_C_MAX_REAL_PRECISION}") |
| 405 |
# ITK -- stop ]] |
| 406 |
|
| 407 |
#----------------------------------------------------------------------------- |
| 408 |
# Macro to determine the various conversion capabilities |
| 409 |
#----------------------------------------------------------------------------- |
| 410 |
macro (H5ConversionTests TEST msg) |
| 411 |
if (NOT DEFINED ${TEST}) |
| 412 |
TRY_RUN (${TEST}_RUN ${TEST}_COMPILE |
| 413 |
${CMAKE_BINARY_DIR} |
| 414 |
${HDF_RESOURCES_DIR}/ConversionTests.c |
| 415 |
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=-D${TEST}_TEST |
| 416 |
OUTPUT_VARIABLE OUTPUT |
| 417 |
) |
| 418 |
if (${TEST}_COMPILE) |
| 419 |
if (${TEST}_RUN EQUAL "0") |
| 420 |
set (${TEST} 1 CACHE INTERNAL ${msg}) |
| 421 |
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") |
| 422 |
message (VERBOSE "${msg}... yes") |
| 423 |
endif () |
| 424 |
else () |
| 425 |
set (${TEST} "" CACHE INTERNAL ${msg}) |
| 426 |
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") |
| 427 |
message (VERBOSE "${msg}... no") |
| 428 |
endif () |
| 429 |
file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log |
| 430 |
"Test ${TEST} Run failed with the following output and exit code:\n ${OUTPUT}\n" |
| 431 |
) |
| 432 |
endif () |
| 433 |
else () |
| 434 |
set (${TEST} "" CACHE INTERNAL ${msg}) |
| 435 |
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") |
| 436 |
message (VERBOSE "${msg}... no") |
| 437 |
endif () |
| 438 |
file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log |
| 439 |
"Test ${TEST} Compile failed with the following output:\n ${OUTPUT}\n" |
| 440 |
) |
| 441 |
endif () |
| 442 |
|
| 443 |
endif () |
| 444 |
endmacro () |
| 445 |
|
| 446 |
#----------------------------------------------------------------------------- |
| 447 |
# Check various conversion capabilities |
| 448 |
#----------------------------------------------------------------------------- |
| 449 |
|
| 450 |
# ---------------------------------------------------------------------- |
| 451 |
# Set the flag to indicate that the machine is using a special algorithm to convert |
| 452 |
# 'long double' to '(unsigned) long' values. (This flag should only be set for |
| 453 |
# the IBM Power6 Linux. When the bit sequence of long double is |
| 454 |
# 0x4351ccf385ebc8a0bfcc2a3c3d855620, the converted value of (unsigned)long |
| 455 |
# is 0x004733ce17af227f, not the same as the library's conversion to 0x004733ce17af2282. |
| 456 |
# The machine's conversion gets the correct value. We define the macro and disable |
| 457 |
# this kind of test until we figure out what algorithm they use. |
| 458 |
#----------------------------------------------------------------------------- |
| 459 |
H5ConversionTests (${HDF_PREFIX}_LDOUBLE_TO_LONG_SPECIAL "Checking IF your system converts long double to (unsigned) long values with special algorithm") |
| 460 |
# ---------------------------------------------------------------------- |
| 461 |
# Set the flag to indicate that the machine is using a special algorithm |
| 462 |
# to convert some values of '(unsigned) long' to 'long double' values. |
| 463 |
# (This flag should be off for all machines, except for IBM Power6 Linux, |
| 464 |
# when the bit sequences are 003fff..., 007fff..., 00ffff..., 01ffff..., |
| 465 |
# ..., 7fffff..., the compiler uses a unknown algorithm. We define a |
| 466 |
# macro and skip the test for now until we know about the algorithm. |
| 467 |
#----------------------------------------------------------------------------- |
| 468 |
H5ConversionTests (${HDF_PREFIX}_LONG_TO_LDOUBLE_SPECIAL "Checking IF your system can convert (unsigned) long to long double values with special algorithm") |
| 469 |
# ---------------------------------------------------------------------- |
| 470 |
# Set the flag to indicate that the machine can accurately convert |
| 471 |
# 'long double' to '(unsigned) long long' values. (This flag should be set for |
| 472 |
# all machines, except for Mac OS 10.4 and SGI IRIX64 6.5. When the bit sequence |
| 473 |
# of long double is 0x4351ccf385ebc8a0bfcc2a3c..., the values of (unsigned)long long |
| 474 |
# start to go wrong on these two machines. Adjusting it higher to |
| 475 |
# 0x4351ccf385ebc8a0dfcc... or 0x4351ccf385ebc8a0ffcc... will make the converted |
| 476 |
# values wildly wrong. This test detects this wrong behavior and disable the test. |
| 477 |
#----------------------------------------------------------------------------- |
| 478 |
H5ConversionTests (${HDF_PREFIX}_LDOUBLE_TO_LLONG_ACCURATE "Checking IF correctly converting long double to (unsigned) long long values") |
| 479 |
# ---------------------------------------------------------------------- |
| 480 |
# Set the flag to indicate that the machine can accurately convert |
| 481 |
# '(unsigned) long long' to 'long double' values. (This flag should be set for |
| 482 |
# all machines, except for Mac OS 10.4, when the bit sequences are 003fff..., |
| 483 |
# 007fff..., 00ffff..., 01ffff..., ..., 7fffff..., the converted values are twice |
| 484 |
# as big as they should be. |
| 485 |
#----------------------------------------------------------------------------- |
| 486 |
H5ConversionTests (${HDF_PREFIX}_LLONG_TO_LDOUBLE_CORRECT "Checking IF correctly converting (unsigned) long long to long double values") |
| 487 |
# ---------------------------------------------------------------------- |
| 488 |
# Set the flag to indicate that the machine can accurately convert |
| 489 |
# some long double values |
| 490 |
#----------------------------------------------------------------------------- |
| 491 |
H5ConversionTests (${HDF_PREFIX}_DISABLE_SOME_LDOUBLE_CONV "Checking IF the cpu is power9 and cannot correctly converting long double values") |
| 492 |
# ---------------------------------------------------------------------- |
| 493 |
# Check if pointer alignments are enforced |
| 494 |
#----------------------------------------------------------------------------- |
| 495 |
H5ConversionTests (${HDF_PREFIX}_NO_ALIGNMENT_RESTRICTIONS "Checking IF alignment restrictions are strictly enforced") |