2019-02-15 04:43:50 +00:00
|
|
|
#
|
|
|
|
# This file is part of the GROMACS molecular simulation package.
|
|
|
|
#
|
|
|
|
# Copyright (c) 2009,2010,2012,2014,2019, by the GROMACS development team, led by
|
|
|
|
# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
|
|
|
|
# and including many others, as listed in the AUTHORS file in the
|
|
|
|
# top-level source directory and at http://www.gromacs.org.
|
|
|
|
#
|
|
|
|
# GROMACS is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2.1
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# GROMACS is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with GROMACS; if not, see
|
|
|
|
# http://www.gnu.org/licenses, or write to the Free Software Foundation,
|
|
|
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
#
|
|
|
|
# If you want to redistribute modifications to GROMACS, please
|
|
|
|
# consider that scientific software is very special. Version
|
|
|
|
# control is crucial - bugs must be traceable. We will be happy to
|
|
|
|
# consider code for inclusion in the official distribution, but
|
|
|
|
# derived work must not be called official GROMACS. Details are found
|
|
|
|
# in the README & COPYING files - if they are missing, get the
|
|
|
|
# official version at http://www.gromacs.org.
|
|
|
|
#
|
|
|
|
# To help us fund GROMACS development, we humbly ask that you cite
|
|
|
|
# the research papers on the package. Check out http://www.gromacs.org.
|
|
|
|
|
|
|
|
# Forked from Gromacs
|
|
|
|
|
|
|
|
# - Define macro to check large file support
|
|
|
|
#
|
|
|
|
# cmlib_test_large_files(VARIABLE)
|
|
|
|
#
|
|
|
|
# VARIABLE will be set to true if off_t is 64 bits, and fseeko/ftello present.
|
|
|
|
# This macro will also set defines necessary enable large file support, for instance
|
|
|
|
# _LARGE_FILES
|
|
|
|
# _LARGEFILE_SOURCE
|
|
|
|
# _FILE_OFFSET_BITS 64
|
|
|
|
# HAVE_FSEEKO
|
|
|
|
# HAVE__FSEEKI64
|
|
|
|
#
|
|
|
|
# However, it is YOUR job to make sure these defines are set in a cmakedefine so they
|
|
|
|
# end up in a config.h file that is included in your source if necessary!
|
|
|
|
|
|
|
|
include(CheckTypeSize)
|
|
|
|
|
2019-10-07 10:52:50 +00:00
|
|
|
macro(cmlib_test_large_files VARIABLE)
|
|
|
|
if(NOT DEFINED ${VARIABLE})
|
2019-02-15 04:43:50 +00:00
|
|
|
|
|
|
|
# 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
|
|
|
|
# (ZFS), so it might be dangerous to indiscriminately set e.g. _FILE_OFFSET_BITS=64.
|
|
|
|
|
2019-10-07 10:52:50 +00:00
|
|
|
message(STATUS "Checking for 64-bit off_t")
|
2019-02-15 04:43:50 +00:00
|
|
|
|
|
|
|
# First check without any special flags
|
2019-12-03 16:23:14 +00:00
|
|
|
try_compile(FILE64_OK "${CMAKE_BINARY_DIR}"
|
|
|
|
"${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c")
|
2019-02-15 04:43:50 +00:00
|
|
|
if(FILE64_OK)
|
2019-10-07 10:52:50 +00:00
|
|
|
message(STATUS "Checking for 64-bit off_t - present")
|
2019-02-15 04:43:50 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT FILE64_OK)
|
|
|
|
# Test with _FILE_OFFSET_BITS=64
|
2019-12-03 16:23:14 +00:00
|
|
|
try_compile(
|
|
|
|
FILE64_OK "${CMAKE_BINARY_DIR}" "${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c"
|
|
|
|
COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=64")
|
2019-02-15 04:43:50 +00:00
|
|
|
if(FILE64_OK)
|
2019-10-07 10:52:50 +00:00
|
|
|
message(STATUS "Checking for 64-bit off_t - present with _FILE_OFFSET_BITS=64")
|
2019-12-03 16:23:14 +00:00
|
|
|
set(_FILE_OFFSET_BITS
|
|
|
|
64
|
|
|
|
CACHE INTERNAL "64-bit off_t requires _FILE_OFFSET_BITS=64")
|
2019-02-15 04:43:50 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT FILE64_OK)
|
|
|
|
# Test with _LARGE_FILES
|
2019-12-03 16:23:14 +00:00
|
|
|
try_compile(
|
|
|
|
FILE64_OK "${CMAKE_BINARY_DIR}" "${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c"
|
|
|
|
COMPILE_DEFINITIONS "-D_LARGE_FILES")
|
2019-02-15 04:43:50 +00:00
|
|
|
if(FILE64_OK)
|
2019-10-07 10:52:50 +00:00
|
|
|
message(STATUS "Checking for 64-bit off_t - present with _LARGE_FILES")
|
2019-12-03 16:23:14 +00:00
|
|
|
set(_LARGE_FILES
|
|
|
|
1
|
|
|
|
CACHE INTERNAL "64-bit off_t requires _LARGE_FILES")
|
2019-02-15 04:43:50 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT FILE64_OK)
|
|
|
|
# Test with _LARGEFILE_SOURCE
|
2019-12-03 16:23:14 +00:00
|
|
|
try_compile(
|
|
|
|
FILE64_OK "${CMAKE_BINARY_DIR}" "${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c"
|
|
|
|
COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE")
|
2019-02-15 04:43:50 +00:00
|
|
|
if(FILE64_OK)
|
2019-10-07 10:52:50 +00:00
|
|
|
message(STATUS "Checking for 64-bit off_t - present with _LARGEFILE_SOURCE")
|
2019-12-03 16:23:14 +00:00
|
|
|
set(_LARGEFILE_SOURCE
|
|
|
|
1
|
|
|
|
CACHE INTERNAL "64-bit off_t requires _LARGEFILE_SOURCE")
|
2019-02-15 04:43:50 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT FILE64_OK)
|
2019-10-07 10:52:50 +00:00
|
|
|
message(STATUS "Checking for 64-bit off_t - not present")
|
2019-02-15 04:43:50 +00:00
|
|
|
else()
|
|
|
|
# 64-bit off_t found. Now check that ftello/fseeko is available.
|
|
|
|
|
|
|
|
# Set the flags we might have determined to be required above
|
|
|
|
configure_file("${CMLIB_MODULE_DIR}/tests/TestLargeFiles.c.in"
|
2019-10-07 10:52:50 +00:00
|
|
|
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
|
2019-02-15 04:43:50 +00:00
|
|
|
|
2019-10-07 10:52:50 +00:00
|
|
|
message(STATUS "Checking for fseeko/ftello")
|
2019-02-15 04:43:50 +00:00
|
|
|
# Test if ftello/fseeko are available
|
2019-10-07 10:52:50 +00:00
|
|
|
try_compile(FSEEKO_COMPILE_OK "${CMAKE_BINARY_DIR}"
|
|
|
|
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
|
2019-02-15 04:43:50 +00:00
|
|
|
if(FSEEKO_COMPILE_OK)
|
2019-10-07 10:52:50 +00:00
|
|
|
message(STATUS "Checking for fseeko/ftello - present")
|
2019-02-15 04:43:50 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT FSEEKO_COMPILE_OK)
|
|
|
|
# glibc 2.2 neds _LARGEFILE_SOURCE for fseeko (but not 64-bit off_t...)
|
2019-12-03 16:23:14 +00:00
|
|
|
try_compile(
|
|
|
|
FSEEKO_COMPILE_OK "${CMAKE_BINARY_DIR}"
|
|
|
|
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c"
|
|
|
|
COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE")
|
2019-02-15 04:43:50 +00:00
|
|
|
if(FSEEKO_COMPILE_OK)
|
2019-10-07 10:52:50 +00:00
|
|
|
message(STATUS "Checking for fseeko/ftello - present with _LARGEFILE_SOURCE")
|
2019-12-03 16:23:14 +00:00
|
|
|
set(_LARGEFILE_SOURCE
|
|
|
|
1
|
|
|
|
CACHE INTERNAL "64-bit fseeko requires _LARGEFILE_SOURCE")
|
2019-02-15 04:43:50 +00:00
|
|
|
else()
|
|
|
|
set(FILE64_OK 0)
|
|
|
|
message(STATUS "64-bit off_t present but fseeko/ftello not found!")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT FILE64_OK)
|
|
|
|
# now check for Windows stuff
|
2019-12-03 16:23:14 +00:00
|
|
|
try_compile(FILE64_OK "${CMAKE_BINARY_DIR}"
|
|
|
|
"${CMLIB_MODULE_DIR}/tests/TestWindowsFSeek.c")
|
2019-02-15 04:43:50 +00:00
|
|
|
if(FILE64_OK)
|
2019-10-07 10:52:50 +00:00
|
|
|
message(STATUS "Checking for 64-bit off_t - present with _fseeki64")
|
2019-12-03 16:23:14 +00:00
|
|
|
set(HAVE__FSEEKI64
|
|
|
|
1
|
|
|
|
CACHE INTERNAL "64-bit off_t requires _fseeki64")
|
2019-02-15 04:43:50 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(FSEEKO_COMPILE_OK)
|
2019-12-03 16:23:14 +00:00
|
|
|
set(${VARIABLE}
|
|
|
|
1
|
|
|
|
CACHE INTERNAL "Result of test for large file support" FORCE)
|
|
|
|
set(HAVE_FSEEKO
|
|
|
|
1
|
|
|
|
CACHE INTERNAL "64bit fseeko is available" FORCE)
|
2019-02-15 04:43:50 +00:00
|
|
|
elseif(HAVE__FSEEKI64)
|
2019-12-03 16:23:14 +00:00
|
|
|
set(${VARIABLE}
|
|
|
|
1
|
|
|
|
CACHE INTERNAL "Result of test for large file support" FORCE)
|
|
|
|
set(HAVE__FSEEKI64
|
|
|
|
1
|
|
|
|
CACHE INTERNAL "Windows 64-bit fseek" FORCE)
|
2019-02-15 04:43:50 +00:00
|
|
|
else()
|
2019-10-07 10:52:50 +00:00
|
|
|
check_type_size("long int" SIZEOF_LONG_INT)
|
2019-02-15 04:43:50 +00:00
|
|
|
if(SIZEOF_LONG_INT EQUAL 8) #standard fseek is OK for 64bit
|
2019-12-03 16:23:14 +00:00
|
|
|
set(${VARIABLE}
|
|
|
|
1
|
|
|
|
CACHE INTERNAL "Result of test for large file support" FORCE)
|
2019-02-15 04:43:50 +00:00
|
|
|
else()
|
2019-10-07 10:52:50 +00:00
|
|
|
message(FATAL_ERROR "Checking for 64bit file support failed.")
|
2019-02-15 04:43:50 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2019-10-07 10:52:50 +00:00
|
|
|
endif()
|
|
|
|
endmacro(cmlib_test_large_files VARIABLE)
|