summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2006-08-22 19:34:14 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2006-08-22 19:34:14 (GMT)
commitd510ef2557df9da0b8949409e73b526d137bd13d (patch)
tree451cf8964f893de26b104b1fb57c102731c9b772 /Source
parent211e991057ed282e6fcf07d8e9212b6136411b10 (diff)
downloadCMake-d510ef2557df9da0b8949409e73b526d137bd13d.zip
CMake-d510ef2557df9da0b8949409e73b526d137bd13d.tar.gz
CMake-d510ef2557df9da0b8949409e73b526d137bd13d.tar.bz2
ENH: Support large file systems in kwsys
Diffstat (limited to 'Source')
-rw-r--r--Source/kwsys/CMakeLists.txt17
-rw-r--r--Source/kwsys/Configure.h.in14
-rw-r--r--Source/kwsys/RequireLargeFilesSupport.cxx28
3 files changed, 59 insertions, 0 deletions
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index 2145b7d..aee68e2 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -241,6 +241,23 @@ IF(NOT KWSYS_IN_SOURCE_BUILD)
${PROJECT_BINARY_DIR}/kwsysPrivate.h COPY_ONLY IMMEDIATE)
ENDIF(NOT KWSYS_IN_SOURCE_BUILD)
+
+IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.4)
+ MESSAGE(STATUS "Skip large files support because CMake is earlier than 2.4")
+ELSE("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.4)
+ INCLUDE(CheckCXXSourceRuns)
+ FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/RequireLargeFilesSupport.cxx"
+ __kwsys_require_large_files_support)
+ CHECK_CXX_SOURCE_RUNS("${__kwsys_require_large_files_support}"
+ REQUIRE_LARGE_FILE_SUPPORT
+ "Support for 64 bit file systems")
+ IF(REQUIRE_LARGE_FILE_SUPPORT)
+ SET(KWSYS_REQUIRE_LARGE_FILE_SUPPORT 1)
+ ELSE(REQUIRE_LARGE_FILE_SUPPORT)
+ SET(KWSYS_REQUIRE_LARGE_FILE_SUPPORT 0)
+ ENDIF(REQUIRE_LARGE_FILE_SUPPORT)
+ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.4)
+
#-----------------------------------------------------------------------------
# We require ANSI support from the C compiler. Add any needed flags.
IF(CMAKE_ANSI_CFLAGS)
diff --git a/Source/kwsys/Configure.h.in b/Source/kwsys/Configure.h.in
index 744e884..5456467 100644
--- a/Source/kwsys/Configure.h.in
+++ b/Source/kwsys/Configure.h.in
@@ -22,6 +22,20 @@
# define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
#endif
+/* This is a support for files on the disk that are larger than 2GB. Since
+ this is the first place that any include should happen, do this here. */
+#if @KWSYS_REQUIRE_LARGE_FILE_SUPPORT@
+# ifndef _LARGEFILE_SOURCE
+# define _LARGEFILE_SOURCE
+# endif
+# ifndef _LARGE_FILES
+# define _LARGE_FILES
+# endif
+# ifndef _FILE_OFFSET_BITS
+# define _FILE_OFFSET_BITS 64
+# endif
+#endif
+
/* Setup the export macro. */
#if defined(_WIN32) && @KWSYS_BUILD_SHARED@
# if defined(@KWSYS_NAMESPACE@_EXPORTS)
diff --git a/Source/kwsys/RequireLargeFilesSupport.cxx b/Source/kwsys/RequireLargeFilesSupport.cxx
new file mode 100644
index 0000000..596bd60
--- /dev/null
+++ b/Source/kwsys/RequireLargeFilesSupport.cxx
@@ -0,0 +1,28 @@
+#define _LARGEFILE_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, 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;
+}
+