summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2011-10-18 16:44:32 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2011-10-18 16:44:32 (GMT)
commitdc90cfc1c2619b3e5455ed2da6a627e1296f1cbc (patch)
treef764d53b7fcdcc384d80fd6d13e0feb4f5a15e2f /config
parentcd38a32601e3aacacd45365f8f129bfe08f08898 (diff)
downloadhdf5-dc90cfc1c2619b3e5455ed2da6a627e1296f1cbc.zip
hdf5-dc90cfc1c2619b3e5455ed2da6a627e1296f1cbc.tar.gz
hdf5-dc90cfc1c2619b3e5455ed2da6a627e1296f1cbc.tar.bz2
[svn-r21596] Correct large file support test
Diffstat (limited to 'config')
-rw-r--r--config/cmake/ConfigureChecks.cmake31
-rw-r--r--config/cmake/HDF5Tests.c31
2 files changed, 60 insertions, 2 deletions
diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake
index 4b2b887..98891ee 100644
--- a/config/cmake/ConfigureChecks.cmake
+++ b/config/cmake/ConfigureChecks.cmake
@@ -295,16 +295,43 @@ ENDIF (H5_HAVE_STDINT_H AND CMAKE_CXX_COMPILER_LOADED)
SET (LINUX_LFS 0)
SET (HDF5_EXTRA_FLAGS)
-IF (CMAKE_SYSTEM MATCHES "Linux-([3-9]\\.[0-9]|2\\.[4-9])\\.")
+#IF (CMAKE_SYSTEM MATCHES "Linux-([3-9]\\.[0-9]|2\\.[4-9])\\.")
+IF (NOT WINDOWS)
# Linux Specific flags
SET (HDF5_EXTRA_FLAGS -D_POSIX_SOURCE -D_BSD_SOURCE)
OPTION (HDF5_ENABLE_LARGE_FILE "Enable support for large (64-bit) files on Linux." ON)
IF (HDF5_ENABLE_LARGE_FILE)
+ SET (msg "Performing TEST_LFS_WORKS")
+ TRY_RUN (TEST_LFS_WORKS_RUN TEST_LFS_WORKS_COMPILE
+ ${HDF5_BINARY_DIR}/CMake
+ ${HDF5_RESOURCES_DIR}/HDF5Tests.c
+ CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=-DTEST_LFS_WORKS
+ OUTPUT_VARIABLE OUTPUT
+ )
+ IF (TEST_LFS_WORKS_COMPILE)
+ IF (TEST_LFS_WORKS_RUN MATCHES 0)
+ SET (TEST_LFS_WORKS 1 CACHE INTERNAL ${msg})
SET (LARGEFILE 1)
SET (HDF5_EXTRA_FLAGS ${HDF5_EXTRA_FLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE)
+ MESSAGE (STATUS "${msg}... yes")
+ ELSE (TEST_LFS_WORKS_RUN MATCHES 0)
+ SET (TEST_LFS_WORKS "" CACHE INTERNAL ${msg})
+ MESSAGE (STATUS "${msg}... no")
+ FILE (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log
+ "Test TEST_LFS_WORKS Run failed with the following output and exit code:\n ${OUTPUT}\n"
+ )
+ ENDIF (TEST_LFS_WORKS_RUN MATCHES 0)
+ ELSE (TEST_LFS_WORKS_COMPILE )
+ SET (TEST_LFS_WORKS "" CACHE INTERNAL ${msg})
+ MESSAGE (STATUS "${msg}... no")
+ FILE (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log
+ "Test TEST_LFS_WORKS Compile failed with the following output:\n ${OUTPUT}\n"
+ )
+ ENDIF (TEST_LFS_WORKS_COMPILE)
ENDIF (HDF5_ENABLE_LARGE_FILE)
SET (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${HDF5_EXTRA_FLAGS})
-ENDIF (CMAKE_SYSTEM MATCHES "Linux-([3-9]\\.[0-9]|2\\.[4-9])\\.")
+ENDIF (NOT WINDOWS)
+#ENDIF (CMAKE_SYSTEM MATCHES "Linux-([3-9]\\.[0-9]|2\\.[4-9])\\.")
ADD_DEFINITIONS (${HDF5_EXTRA_FLAGS})
diff --git a/config/cmake/HDF5Tests.c b/config/cmake/HDF5Tests.c
index f580bbc..79741a8 100644
--- a/config/cmake/HDF5Tests.c
+++ b/config/cmake/HDF5Tests.c
@@ -336,6 +336,37 @@ int main()
}
#endif
+#ifdef TEST_LFS_WORKS
+/* Return 0 when LFS is available and 1 otherwise. */
+#define _LARGEFILE_SOURCE
+#define _LARGEFILE64_SOURCE
+#define _LARGE_FILES
+#define _FILE_OFFSET_BITS 64
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <assert.h>
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+ /* check that off_t can hold 2^63 - 1 and perform basic operations... */
+#define OFF_T_64 (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+ if (OFF_T_64 % 2147483647 != 1)
+ return 1;
+
+ // stat breaks on SCO OpenServer
+ struct stat buf;
+ stat( argv[0], &buf );
+ if (!S_ISREG(buf.st_mode))
+ return 2;
+
+ FILE *file = fopen( argv[0], "r" );
+ off_t offset = ftello( file );
+ fseek( file, offset, SEEK_CUR );
+ fclose( file );
+ return 0;
+}
+#endif
#ifdef GETTIMEOFDAY_GIVES_TZ
#ifdef HAVE_SYS_TIME_H