From ffb1a9f80ad4e604c11c24a2f8769e93ba035ab3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 25 Aug 2006 16:00:10 -0400 Subject: [PATCH] ENH: Moved test for large file support into kwsysPlatformCxxTests.cxx with name KWSYS_LFS_WORKS. --- Source/kwsys/CMakeLists.txt | 40 +++++++++++++---------- Source/kwsys/Configure.h.in | 2 +- Source/kwsys/RequireLargeFilesSupport.cxx | 28 ---------------- Source/kwsys/kwsysPlatformCxxTests.cxx | 32 ++++++++++++++++++ 4 files changed, 56 insertions(+), 46 deletions(-) delete mode 100644 Source/kwsys/RequireLargeFilesSupport.cxx diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 291a7af60..b4bd93c4b 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/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) diff --git a/Source/kwsys/Configure.h.in b/Source/kwsys/Configure.h.in index 545646755..ba4b99cb6 100644 --- a/Source/kwsys/Configure.h.in +++ b/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 diff --git a/Source/kwsys/RequireLargeFilesSupport.cxx b/Source/kwsys/RequireLargeFilesSupport.cxx deleted file mode 100644 index 596bd6078..000000000 --- a/Source/kwsys/RequireLargeFilesSupport.cxx +++ /dev/null @@ -1,28 +0,0 @@ -#define _LARGEFILE_SOURCE -#define _LARGE_FILES -#define _FILE_OFFSET_BITS 64 -#include -#include -#include -#include - -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; -} - diff --git a/Source/kwsys/kwsysPlatformCxxTests.cxx b/Source/kwsys/kwsysPlatformCxxTests.cxx index 8048acff8..989bf1bbe 100644 --- a/Source/kwsys/kwsysPlatformCxxTests.cxx +++ b/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 +#include +#include +#include + +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. */