1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-24 00:34:04 +00:00
transmission/cmake/LargeFileSupport.cmake
Mike Gelfand a2037bdbbd Define one of LFS macros instead of using xxx64 functions directly.
There're too many functions and types to consider, and benefits of not
using LFS macros aren't that big (I was thinking of using fts(3) but
that may not happen soon or at all).
2015-03-10 22:31:09 +00:00

33 lines
1.4 KiB
CMake

# Based on AC_SYS_LARGEFILE
if(NOT DEFINED NO_LFS_MACROS_REQUIRED)
include(CheckCSourceCompiles)
# Check that off_t can represent 2**63 - 1 correctly.
# We can't simply define LARGE_OFF_T to be 9223372036854775807,
# since some C++ compilers masquerading as C compilers
# incorrectly reject 9223372036854775807.
set(LFS_TEST_PROGRAM "
#include <sys/types.h>
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1];
int main() { return 0; }
")
check_c_source_compiles("${LFS_TEST_PROGRAM}" NO_LFS_MACROS_REQUIRED)
if(NOT NO_LFS_MACROS_REQUIRED)
if(NOT DEFINED FILE_OFFSET_BITS_LFS_MACRO_REQUIRED)
check_c_source_compiles("#define _FILE_OFFSET_BITS 64 ${LFS_TEST_PROGRAM}" FILE_OFFSET_BITS_LFS_MACRO_REQUIRED)
if(FILE_OFFSET_BITS_LFS_MACRO_REQUIRED)
add_definitions(-D_FILE_OFFSET_BITS=64)
elseif(NOT DEFINED LARGE_FILES_LFS_MACRO_REQUIRED)
check_c_source_compiles("#define _LARGE_FILES 1 ${LFS_TEST_PROGRAM}" LARGE_FILES_LFS_MACRO_REQUIRED)
if(LARGE_FILES_LFS_MACRO_REQUIRED)
add_definitions(-D_LARGE_FILES=1)
endif()
endif()
endif()
endif()
unset(LFS_TEST_PROGRAM)
endif()