瀏覽代碼

ENH: Moved test for large file support into kwsysPlatformCxxTests.cxx with name KWSYS_LFS_WORKS.

Brad King 19 年之前
父節點
當前提交
ffb1a9f80a

+ 23 - 17
Source/kwsys/CMakeLists.txt

@@ -142,6 +142,9 @@ IF(KWSYS_STANDALONE)
   ENDIF(BUILD_TESTING)
 ENDIF(KWSYS_STANDALONE)
 
+# Include helper macros.
+INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformCxxTests.cmake)
+
 # Do full dependency headers.
 INCLUDE_REGULAR_EXPRESSION("^.*$")
 
@@ -241,22 +244,6 @@ IF(NOT KWSYS_IN_SOURCE_BUILD)
     ${PROJECT_BINARY_DIR}/kwsysPrivate.h COPY_ONLY IMMEDIATE)
 ENDIF(NOT KWSYS_IN_SOURCE_BUILD)
 
-
-SET(KWSYS_REQUIRE_LARGE_FILE_SUPPORT 0)
-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(${CMAKE_CURRENT_SOURCE_DIR}/CheckCXXSourceRuns.cmake)
-  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)
-  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)
@@ -280,11 +267,30 @@ IF(NOT CMAKE_COMPILER_IS_GNUCXX)
   ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
 ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX)
 
+#-----------------------------------------------------------------------------
+# Configure Large File Support.
+SET(KWSYS_LFS_REQUESTED 1)
+SET(KWSYS_LFS_AVAILABLE 0)
+IF(KWSYS_LFS_REQUESTED)
+  # Large File Support is requested.
+  SET(KWSYS_LFS_REQUESTED 1)
+
+  # Check for large file support.
+  KWSYS_PLATFORM_CXX_TEST_RUN(KWSYS_LFS_WORKS
+    "Checking for Large File Support" DIRECT)
+
+  IF(KWSYS_LFS_WORKS)
+    SET(KWSYS_LFS_AVAILABLE 1)
+  ENDIF(KWSYS_LFS_WORKS)
+ELSE(KWSYS_LFS_REQUESTED)
+  # Large File Support is not requested.
+  SET(KWSYS_LFS_REQUESTED 0)
+ENDIF(KWSYS_LFS_REQUESTED)
+
 #-----------------------------------------------------------------------------
 # Configure the standard library header wrappers based on compiler's
 # capabilities and parent project's request.  Enforce 0/1 as only
 # possible values for configuration into Configure.hxx.
-INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformCxxTests.cmake)
 
 KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAVE_STD
   "Checking whether STL classes are in std namespace" DIRECT)

+ 1 - 1
Source/kwsys/Configure.h.in

@@ -24,7 +24,7 @@
 
 /* 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@
+#if @KWSYS_LFS_AVAILABLE@
 #  ifndef _LARGEFILE_SOURCE
 #    define _LARGEFILE_SOURCE
 #  endif

+ 0 - 28
Source/kwsys/RequireLargeFilesSupport.cxx

@@ -1,28 +0,0 @@
-#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;
-}
-

+ 32 - 0
Source/kwsys/kwsysPlatformCxxTests.cxx

@@ -275,6 +275,38 @@ int main()
 }
 #endif
 
+#ifdef TEST_KWSYS_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, 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 TEST_KWSYS_CXX_TYPE_INFO
 /* Collect fundamental type information and save it to a CMake script.  */