Clean up tests.

On Windows with MSVC, just assume we have 64-bit file offset support,
including _fseeki64() and _ftelli64().

On UN*X, test for Large File Support and for fseeko()/ftello(), and for
what #defines are needed to enable them.

On Windows without MSVC, test for Large File Support, but assume we have
_fseeki64() and _ftelli64(); what *should* we be doing?

Clean up indentation and else()/endif() arguments while we're at it.

Change-Id: I801d1f4059abbed2d5123d2375a560634a9ee056
Reviewed-on: https://code.wireshark.org/review/28781
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2018-07-20 14:13:43 -07:00
parent 977f4c2e68
commit b622b1f5c1
1 changed files with 96 additions and 85 deletions

View File

@ -20,11 +20,31 @@
MACRO(GMX_TEST_LARGE_FILES VARIABLE) MACRO(GMX_TEST_LARGE_FILES VARIABLE)
IF(NOT DEFINED ${VARIABLE}) IF(NOT DEFINED ${VARIABLE})
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
# On most platforms it is probably overkill to first test the flags for 64-bit off_t, #
# and then separately fseeko. However, in the future we might have 128-bit filesystems # This is Visual Studio; Visual Studio has supported
# (ZFS), so it might be dangerous to indiscriminately set e.g. _FILE_OFFSET_BITS=64. # _fseeki64 and _ftelli64 since Visual Studio 2005 / MSVCR80,
# and we require newer versions, so we know we have them.
#
MESSAGE(STATUS "_fseeki64 and _ftelli64 are present")
else(CMAKE_C_COMPILER_ID MATCHES "MSVC")
#
# This is UN*X, or some other Windows compiler.
#
# For UN*X, we do the Large File Support tests, to see
# whether it's present and, if so what we need to define
# to enable it.
#
# XXX - what's the right thing to do on Windows with,
# for example, MinGW?
#
# On most platforms it is probably overkill to first test
# the flags for 64-bit off_t, and then separately fseeko.
# However, in the future we might have 128-bit seek offsets
# to support 128-bit filesystems that allow 128-bit offsets
# (ZFS), so it might be dangerous to indiscriminately set
# e.g. _FILE_OFFSET_BITS=64.
#
MESSAGE(STATUS "Checking for 64-bit off_t") MESSAGE(STATUS "Checking for 64-bit off_t")
# First check without any special flags # First check without any special flags
@ -67,21 +87,18 @@ MACRO(GMX_TEST_LARGE_FILES VARIABLE)
endif(FILE64_OK) endif(FILE64_OK)
endif(NOT FILE64_OK) endif(NOT FILE64_OK)
if(NOT FILE64_OK AND WIN32)
# Visual C++ has supported fseeki64 since Visual Studio 2005 / MSVCR80.
MESSAGE(STATUS "64-bit off_t is not present")
MESSAGE(STATUS "_fseeki64 is present")
set(HAVE__FSEEKI64 1 CACHE INTERNAL "64-bit file offsets require _fseeki64")
endif(NOT FILE64_OK)
if(NOT FILE64_OK) if(NOT FILE64_OK)
MESSAGE(STATUS "64-bit file offset support not available") MESSAGE(STATUS "64-bit file offset support not available")
else(NOT FILE64_OK) else(NOT FILE64_OK)
# Set the flags we might have determined to be required above # Set the flags we might have determined to be required above
configure_file("${CMAKE_SOURCE_DIR}/cmake/TestLargeFiles.c.cmakein" configure_file("${CMAKE_SOURCE_DIR}/cmake/TestLargeFiles.c.cmakein"
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c") "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
#
# If this is Windows, assume we have _fseeki64/_ftelli64
# available. If this is UN*X, check for fseeko/ftello.
#
if(NOT WIN32)
MESSAGE(STATUS "Checking for fseeko/ftello") MESSAGE(STATUS "Checking for fseeko/ftello")
# Test if ftello/fseeko are available # Test if ftello/fseeko are available
TRY_COMPILE(FSEEKO_COMPILE_OK "${CMAKE_BINARY_DIR}" TRY_COMPILE(FSEEKO_COMPILE_OK "${CMAKE_BINARY_DIR}"
@ -100,22 +117,16 @@ MACRO(GMX_TEST_LARGE_FILES VARIABLE)
set(_LARGEFILE_SOURCE 1 CACHE INTERNAL "64-bit fseeko requires _LARGEFILE_SOURCE") set(_LARGEFILE_SOURCE 1 CACHE INTERNAL "64-bit fseeko requires _LARGEFILE_SOURCE")
endif(FSEEKO_COMPILE_OK) endif(FSEEKO_COMPILE_OK)
endif(NOT FSEEKO_COMPILE_OK) endif(NOT FSEEKO_COMPILE_OK)
endif(NOT FILE64_OK)
if(FSEEKO_COMPILE_OK) if(FSEEKO_COMPILE_OK)
SET(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE) SET(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE)
set(HAVE_FSEEKO 1 CACHE INTERNAL "64-bit fseeko is available" FORCE) set(HAVE_FSEEKO 1 CACHE INTERNAL "64-bit fseeko is available" FORCE)
else(FSEEKO_COMPILE_OK) else(FSEEKO_COMPILE_OK)
if (HAVE__FSEEKI64)
SET(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE)
SET(HAVE__FSEEKI64 1 CACHE INTERNAL "Windows 64-bit fseek" FORCE)
else (HAVE__FSEEKI64)
MESSAGE(STATUS "Checking for fseeko/ftello - not found") MESSAGE(STATUS "Checking for fseeko/ftello - not found")
SET(${VARIABLE} 0 CACHE INTERNAL "Result of test for large file support" FORCE) SET(${VARIABLE} 0 CACHE INTERNAL "Result of test for large file support" FORCE)
endif (HAVE__FSEEKI64)
endif(FSEEKO_COMPILE_OK) endif(FSEEKO_COMPILE_OK)
endif(NOT WIN32)
endif(NOT FILE64_OK)
endif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
ENDIF(NOT DEFINED ${VARIABLE}) ENDIF(NOT DEFINED ${VARIABLE})
ENDMACRO(GMX_TEST_LARGE_FILES VARIABLE) ENDMACRO(GMX_TEST_LARGE_FILES VARIABLE)