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://support.hdfgroup.org/ftp/HDF5/releases. 9# If you do not have access to either file, you may request a copy from 10# help@hdfgroup.org. 11# 12#----------------------------------------------------------------------------- 13# Include all the necessary files for macros 14#----------------------------------------------------------------------------- 15set (HDF_PREFIX "H5") 16include (${HDF_RESOURCES_EXT_DIR}/ConfigureChecks.cmake) 17 18#----------------------------------------------------------------------------- 19# Option to Clear File Buffers before write --enable-clear-file-buffers 20#----------------------------------------------------------------------------- 21option (HDF5_Enable_Clear_File_Buffers "Securely clear file buffers before writing to file" ON) 22if (HDF5_Enable_Clear_File_Buffers) 23 set (H5_CLEAR_MEMORY 1) 24endif () 25MARK_AS_ADVANCED (HDF5_Enable_Clear_File_Buffers) 26 27#----------------------------------------------------------------------------- 28# Option for --enable-strict-format-checks 29#----------------------------------------------------------------------------- 30option (HDF5_STRICT_FORMAT_CHECKS "Whether to perform strict file format checks" OFF) 31if (HDF5_STRICT_FORMAT_CHECKS) 32 set (H5_STRICT_FORMAT_CHECKS 1) 33endif () 34MARK_AS_ADVANCED (HDF5_STRICT_FORMAT_CHECKS) 35 36#----------------------------------------------------------------------------- 37# Option for --enable-metadata-trace-file 38#----------------------------------------------------------------------------- 39option (HDF5_METADATA_TRACE_FILE "Enable metadata trace file collection" OFF) 40if (HDF5_METADATA_TRACE_FILE) 41 set (H5_METADATA_TRACE_FILE 1) 42endif () 43MARK_AS_ADVANCED (HDF5_METADATA_TRACE_FILE) 44 45# ---------------------------------------------------------------------- 46# Decide whether the data accuracy has higher priority during data 47# conversions. If not, some hard conversions will still be prefered even 48# though the data may be wrong (for example, some compilers don't 49# support denormalized floating values) to maximize speed. 50# 51option (HDF5_WANT_DATA_ACCURACY "IF data accuracy is guaranteed during data conversions" ON) 52if (HDF5_WANT_DATA_ACCURACY) 53 set (H5_WANT_DATA_ACCURACY 1) 54endif () 55MARK_AS_ADVANCED (HDF5_WANT_DATA_ACCURACY) 56 57# ---------------------------------------------------------------------- 58# Decide whether the presence of user's exception handling functions is 59# checked and data conversion exceptions are returned. This is mainly 60# for the speed optimization of hard conversions. Soft conversions can 61# actually benefit little. 62# 63option (HDF5_WANT_DCONV_EXCEPTION "exception handling functions is checked during data conversions" ON) 64if (HDF5_WANT_DCONV_EXCEPTION) 65 set (H5_WANT_DCONV_EXCEPTION 1) 66endif () 67MARK_AS_ADVANCED (HDF5_WANT_DCONV_EXCEPTION) 68 69# ---------------------------------------------------------------------- 70# Check if they would like the function stack support compiled in 71# 72option (HDF5_ENABLE_CODESTACK "Enable the function stack tracing (for developer debugging)." OFF) 73if (HDF5_ENABLE_CODESTACK) 74 set (H5_HAVE_CODESTACK 1) 75endif () 76MARK_AS_ADVANCED (HDF5_ENABLE_CODESTACK) 77 78#----------------------------------------------------------------------------- 79# Are we going to use HSIZE_T 80#----------------------------------------------------------------------------- 81option (HDF5_ENABLE_HSIZET "Enable datasets larger than memory" ON) 82if (HDF5_ENABLE_HSIZET) 83 set (${HDF_PREFIX}_HAVE_LARGE_HSIZET 1) 84endif () 85 86# so far we have no check for this 87set (H5_HAVE_TMPFILE 1) 88 89# TODO -------------------------------------------------------------------------- 90# Should the Default Virtual File Driver be compiled? 91# This is hard-coded now but option should added to match configure 92# 93set (H5_DEFAULT_VFD H5FD_SEC2) 94 95if (NOT DEFINED "H5_DEFAULT_PLUGINDIR") 96 if (WINDOWS) 97 set (H5_DEFAULT_PLUGINDIR "%ALLUSERSPROFILE%\\\\hdf5\\\\lib\\\\plugin") 98 else () 99 set (H5_DEFAULT_PLUGINDIR "/usr/local/hdf5/lib/plugin") 100 endif () 101endif () 102 103if (WINDOWS) 104 set (H5_HAVE_WINDOWS 1) 105 # ---------------------------------------------------------------------- 106 # Set the flag to indicate that the machine has window style pathname, 107 # that is, "drive-letter:\" (e.g. "C:") or "drive-letter:/" (e.g. "C:/"). 108 # (This flag should be _unset_ for all machines, except for Windows) 109 set (H5_HAVE_WINDOW_PATH 1) 110endif () 111 112# ---------------------------------------------------------------------- 113# END of WINDOWS Hard code Values 114# ---------------------------------------------------------------------- 115 116CHECK_FUNCTION_EXISTS (difftime H5_HAVE_DIFFTIME) 117 118# Find the library containing clock_gettime() 119if (NOT WINDOWS) 120 CHECK_FUNCTION_EXISTS (clock_gettime CLOCK_GETTIME_IN_LIBC) 121 CHECK_LIBRARY_EXISTS (rt clock_gettime "" CLOCK_GETTIME_IN_LIBRT) 122 CHECK_LIBRARY_EXISTS (posix4 clock_gettime "" CLOCK_GETTIME_IN_LIBPOSIX4) 123 if (CLOCK_GETTIME_IN_LIBC) 124 set (H5_HAVE_CLOCK_GETTIME 1) 125 elseif (CLOCK_GETTIME_IN_LIBRT) 126 set (H5_HAVE_CLOCK_GETTIME 1) 127 list (APPEND LINK_LIBS rt) 128 elseif (CLOCK_GETTIME_IN_LIBPOSIX4) 129 set (H5_HAVE_CLOCK_GETTIME 1) 130 list (APPEND LINK_LIBS posix4) 131 endif () 132endif () 133#----------------------------------------------------------------------------- 134 135#----------------------------------------------------------------------------- 136# Check if Direct I/O driver works 137#----------------------------------------------------------------------------- 138if (NOT WINDOWS) 139 option (HDF5_ENABLE_DIRECT_VFD "Build the Direct I/O Virtual File Driver" OFF) 140 if (HDF5_ENABLE_DIRECT_VFD) 141 set (msg "Performing TEST_DIRECT_VFD_WORKS") 142 set (MACRO_CHECK_FUNCTION_DEFINITIONS "-DTEST_DIRECT_VFD_WORKS -D_GNU_SOURCE ${CMAKE_REQUIRED_FLAGS}") 143 TRY_RUN (TEST_DIRECT_VFD_WORKS_RUN TEST_DIRECT_VFD_WORKS_COMPILE 144 ${CMAKE_BINARY_DIR} 145 ${HDF_RESOURCES_EXT_DIR}/HDFTests.c 146 CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} 147 OUTPUT_VARIABLE OUTPUT 148 ) 149 if (TEST_DIRECT_VFD_WORKS_COMPILE) 150 if (TEST_DIRECT_VFD_WORKS_RUN MATCHES 0) 151 HDF_FUNCTION_TEST (HAVE_DIRECT) 152 set (CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE") 153 add_definitions ("-D_GNU_SOURCE") 154 else () 155 set (TEST_DIRECT_VFD_WORKS "" CACHE INTERNAL ${msg}) 156 message (STATUS "${msg}... no") 157 file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log 158 "Test TEST_DIRECT_VFD_WORKS Run failed with the following output and exit code:\n ${OUTPUT}\n" 159 ) 160 endif () 161 else () 162 set (TEST_DIRECT_VFD_WORKS "" CACHE INTERNAL ${msg}) 163 message (STATUS "${msg}... no") 164 file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log 165 "Test TEST_DIRECT_VFD_WORKS Compile failed with the following output:\n ${OUTPUT}\n" 166 ) 167 endif () 168 endif () 169endif () 170 171 172#----------------------------------------------------------------------------- 173# Macro to determine the various conversion capabilities 174#----------------------------------------------------------------------------- 175macro (H5ConversionTests TEST msg) 176 if (NOT DEFINED ${TEST}) 177 # message (STATUS "===> ${TEST}") 178 TRY_RUN (${TEST}_RUN ${TEST}_COMPILE 179 ${CMAKE_BINARY_DIR} 180 ${HDF_RESOURCES_DIR}/ConversionTests.c 181 CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=-D${TEST}_TEST 182 OUTPUT_VARIABLE OUTPUT 183 ) 184 if (${TEST}_COMPILE) 185 if (${TEST}_RUN MATCHES 0) 186 set (${TEST} 1 CACHE INTERNAL ${msg}) 187 message (STATUS "${msg}... yes") 188 else () 189 set (${TEST} "" CACHE INTERNAL ${msg}) 190 message (STATUS "${msg}... no") 191 file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log 192 "Test ${TEST} Run failed with the following output and exit code:\n ${OUTPUT}\n" 193 ) 194 endif () 195 else () 196 set (${TEST} "" CACHE INTERNAL ${msg}) 197 message (STATUS "${msg}... no") 198 file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log 199 "Test ${TEST} Compile failed with the following output:\n ${OUTPUT}\n" 200 ) 201 endif () 202 203 endif () 204endmacro () 205 206#----------------------------------------------------------------------------- 207# Check various conversion capabilities 208#----------------------------------------------------------------------------- 209 210# ---------------------------------------------------------------------- 211# Set the flag to indicate that the machine is using a special algorithm to convert 212# 'long double' to '(unsigned) long' values. (This flag should only be set for 213# the IBM Power6 Linux. When the bit sequence of long double is 214# 0x4351ccf385ebc8a0bfcc2a3c3d855620, the converted value of (unsigned)long 215# is 0x004733ce17af227f, not the same as the library's conversion to 0x004733ce17af2282. 216# The machine's conversion gets the correct value. We define the macro and disable 217# this kind of test until we figure out what algorithm they use. 218# 219H5ConversionTests (H5_LDOUBLE_TO_LONG_SPECIAL "Checking IF your system converts long double to (unsigned) long values with special algorithm") 220# ---------------------------------------------------------------------- 221# Set the flag to indicate that the machine is using a special algorithm 222# to convert some values of '(unsigned) long' to 'long double' values. 223# (This flag should be off for all machines, except for IBM Power6 Linux, 224# when the bit sequences are 003fff..., 007fff..., 00ffff..., 01ffff..., 225# ..., 7fffff..., the compiler uses a unknown algorithm. We define a 226# macro and skip the test for now until we know about the algorithm. 227# 228H5ConversionTests (H5_LONG_TO_LDOUBLE_SPECIAL "Checking IF your system can convert (unsigned) long to long double values with special algorithm") 229# ---------------------------------------------------------------------- 230# Set the flag to indicate that the machine can accurately convert 231# 'long double' to '(unsigned) long long' values. (This flag should be set for 232# all machines, except for Mac OS 10.4 and SGI IRIX64 6.5. When the bit sequence 233# of long double is 0x4351ccf385ebc8a0bfcc2a3c..., the values of (unsigned)long long 234# start to go wrong on these two machines. Adjusting it higher to 235# 0x4351ccf385ebc8a0dfcc... or 0x4351ccf385ebc8a0ffcc... will make the converted 236# values wildly wrong. This test detects this wrong behavior and disable the test. 237# 238H5ConversionTests (H5_LDOUBLE_TO_LLONG_ACCURATE "Checking IF correctly converting long double to (unsigned) long long values") 239# ---------------------------------------------------------------------- 240# Set the flag to indicate that the machine can accurately convert 241# '(unsigned) long long' to 'long double' values. (This flag should be set for 242# all machines, except for Mac OS 10.4, when the bit sequences are 003fff..., 243# 007fff..., 00ffff..., 01ffff..., ..., 7fffff..., the converted values are twice 244# as big as they should be. 245# 246H5ConversionTests (H5_LLONG_TO_LDOUBLE_CORRECT "Checking IF correctly converting (unsigned) long long to long double values") 247# ---------------------------------------------------------------------- 248# Check if pointer alignments are enforced 249# 250H5ConversionTests (H5_NO_ALIGNMENT_RESTRICTIONS "Checking IF alignment restrictions are strictly enforced") 251 252# ----------------------------------------------------------------------- 253# wrapper script variables 254# 255set (prefix ${CMAKE_INSTALL_PREFIX}) 256set (exec_prefix "\${prefix}") 257set (libdir "${exec_prefix}/lib") 258set (includedir "\${prefix}/include") 259set (host_os ${CMAKE_HOST_SYSTEM_NAME}) 260set (CC ${CMAKE_C_COMPILER}) 261set (CXX ${CMAKE_CXX_COMPILER}) 262set (FC ${CMAKE_Fortran_COMPILER}) 263foreach (LINK_LIB ${LINK_LIBS}) 264 set (LIBS "${LIBS} -l${LINK_LIB}") 265endforeach () 266