@@ -169,9 +169,7 @@ macro (HDF_FUNCTION_TEST OTHER_TEST)
169169 )
170170 endif ()
171171
172- if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0" )
173- message (TRACE "Performing ${OTHER_TEST} " )
174- endif ()
172+ message (TRACE "Performing ${OTHER_TEST} " )
175173 try_compile (${OTHER_TEST}
176174 ${CMAKE_BINARY_DIR}
177175 ${H5BITGROOM_RESOURCES_DIR} /H5PLTests.c
@@ -194,24 +192,13 @@ macro (HDF_FUNCTION_TEST OTHER_TEST)
194192endmacro ()
195193
196194#-----------------------------------------------------------------------------
197- # Check for these functions before the time headers are checked
198- #-----------------------------------------------------------------------------
199- HDF_FUNCTION_TEST (STDC_HEADERS)
200-
201- #-----------------------------------------------------------------------------
202- # Check for large file support
195+ # Platform-specific flags
203196#-----------------------------------------------------------------------------
204197
205- # The linux-lfs option is deprecated.
206- set (LINUX_LFS 0)
207-
208198set (HDF_EXTRA_C_FLAGS)
209- set (HDF_EXTRA_FLAGS)
210- if (MINGW OR NOT WINDOWS)
211- # Might want to check explicitly for Linux and possibly Cygwin
212- # instead of checking for not Solaris or Darwin.
213- if (NOT HAVE_SOLARIS AND NOT HAVE_DARWIN)
214- # Linux Specific flags
199+
200+ # Linux-specific flags
201+ if (CMAKE_SYSTEM_NAME MATCHES "Linux" )
215202 # This was originally defined as _POSIX_SOURCE which was updated to
216203 # _POSIX_C_SOURCE=199506L to expose a greater amount of POSIX
217204 # functionality so clock_gettime and CLOCK_MONOTONIC are defined
@@ -222,42 +209,36 @@ if (MINGW OR NOT WINDOWS)
222209 # http://www.gnu.org/s/libc/manual/html_node/Feature-Test-Macros.html
223210 set (HDF_EXTRA_C_FLAGS -D_POSIX_C_SOURCE=200809L)
224211
225- option (HDF_ENABLE_LARGE_FILE "Enable support for large (64-bit) files on Linux." ON )
226- if (HDF_ENABLE_LARGE_FILE AND NOT DEFINED TEST_LFS_WORKS_RUN)
227- set (msg "Performing TEST_LFS_WORKS" )
228- try_run (TEST_LFS_WORKS_RUN TEST_LFS_WORKS_COMPILE
229- ${CMAKE_BINARY_DIR}
230- ${H5BITGROOM_RESOURCES_DIR} /H5PLTests.c
231- COMPILE_DEFINITIONS "-DTEST_LFS_WORKS"
232- )
212+ # Set up large file support. This is only necessary on 32-bit systems
213+ # but is used on all Linux systems. It has no effect on 64-bit systems
214+ # so it's not worth hacking up a 32/64-bit test to selectively include it.
215+ #
216+ # The library currently does not use any of the 64-flavored API calls
217+ # or types
218+ set (HDF_EXTRA_C_FLAGS ${HDF_EXTRA_C_FLAGS} -D_LARGEFILE_SOURCE)
219+ set (HDF_EXTRA_C_FLAGS ${HDF_EXTRA_C_FLAGS} -D_FILE_OFFSET_BITS=64 )
233220
234- # The LARGEFILE definitions were from the transition period
235- # and are probably no longer needed. The FILE_OFFSET_BITS
236- # check should be generalized for all POSIX systems as it
237- # is in the Autotools.
238- if (TEST_LFS_WORKS_COMPILE)
239- if (TEST_LFS_WORKS_RUN MATCHES 0)
240- set (TEST_LFS_WORKS 1 CACHE INTERNAL ${msg} )
241- set (LARGEFILE 1)
242- set (HDF_EXTRA_FLAGS ${HDF_EXTRA_FLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE)
243- message (VERBOSE "${msg} ... yes" )
244- else ()
245- set (TEST_LFS_WORKS "" CACHE INTERNAL ${msg} )
246- message (VERBOSE "${msg} ... no" )
247- file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY} /CMakeError.log
248- "Test TEST_LFS_WORKS Run failed with the following exit code:\n ${TEST_LFS_WORKS_RUN} \n "
249- )
250- endif ()
251- else ()
252- set (TEST_LFS_WORKS "" CACHE INTERNAL ${msg} )
253- message (VERBOSE "${msg} ... no" )
254- file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY} /CMakeError.log
255- "Test TEST_LFS_WORKS Compile failed\n "
256- )
257- endif ()
258- endif ()
259- set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${HDF_EXTRA_FLAGS} )
260- endif ()
221+ set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${HDF_EXTRA_C_FLAGS} )
222+ endif ()
223+
224+ # As of 2024, both AIX and Solaris are uncommon, but still exist! The default
225+ # compiler options are also often set to -m32, which produces 32-bit binaries.
226+
227+ # 32-bit AIX compiles might require _LARGE_FILES, but we don't have a system on
228+ # which to test this (yet).
229+ #
230+ # https://www.ibm.com/docs/en/aix/7.1?topic=volumes-writing-programs-that-access-large-files
231+
232+ # 32-bit Solaris probably needs _LARGEFILE_SOURCE and _FILE_OFFSET_BITS=64,
233+ # as in Linux, above.
234+ #
235+ # https://docs.oracle.com/cd/E23824_01/html/821-1474/lfcompile-5.html
236+
237+ # MinGW and Cygwin
238+ if (MINGW OR CYGWIN )
239+ set (CMAKE_REQUIRED_DEFINITIONS
240+ "${CURRENT_TEST_DEFINITIONS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE"
241+ )
261242endif ()
262243
263244#-----------------------------------------------------------------------------
@@ -266,15 +247,11 @@ endif ()
266247macro (HDF_CHECK_TYPE_SIZE type var)
267248 set (aType ${type} )
268249 set (aVar ${var} )
269- if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0" )
270- message (TRACE "Checking size of ${aType} and storing into ${aVar} " )
271- endif ()
250+ message (TRACE "Checking size of ${aType} and storing into ${aVar} " )
272251 CHECK_TYPE_SIZE (${aType} ${aVar} )
273252 if (NOT ${aVar} )
274253 set (${aVar} 0 CACHE INTERNAL "SizeOf for ${aType} " )
275- if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0" )
276- message (TRACE "Size of ${aType} was NOT Found" )
277- endif ()
254+ message (TRACE "Size of ${aType} was NOT Found" )
278255 endif ()
279256endmacro ()
280257
0 commit comments