Add tde_setup_largefiles macro.

The macro sets the necessary definitions so that the default libc
filesystem interface will be for large files on all architectures.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/19/head
Slávek Banko 6 years ago
parent 4512d95ca6
commit 8d8c763683
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -1927,6 +1927,92 @@ macro( tde_setup_msgfmt )
endmacro( )
################################################
#####
##### tde_setup_largefiles
macro( tde_setup_largefiles )
if( NOT DEFINED HAVE_LARGEFILES )
message( STATUS "Check support for large files" )
unset( LARGEFILES_DEFINITIONS )
# check without special definitions
unset( HAVE_SIZEOF_T CACHE )
check_type_size( off_t SIZEOF_OFF_T )
if( SIZEOF_OFF_T GREATER 7 )
set( HAVE_LARGEFILES 1 )
endif( )
# check with definition _FILE_OFFSET_BITS=64
if( NOT HAVE_LARGEFILES )
unset( HAVE_SIZEOF_OFF_T CACHE )
tde_save_and_set( CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_FILE_OFFSET_BITS=64" )
check_type_size( off_t SIZEOF_OFF_T )
tde_restore( CMAKE_REQUIRED_DEFINITIONS )
if( SIZEOF_OFF_T GREATER 7 )
set( LARGEFILES_DEFINITIONS "-D_FILE_OFFSET_BITS=64" )
set( HAVE_LARGEFILES 1 )
endif( )
endif( )
# check with definition _LARGE_FILES
if( NOT HAVE_LARGEFILES )
unset( HAVE_SIZEOF_OFF_T CACHE )
tde_save_and_set( CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_LARGE_FILES" )
check_type_size( off_t SIZEOF_OFF_T )
tde_restore( CMAKE_REQUIRED_DEFINITIONS )
if( SIZEOF_OFF_T GREATER 7 )
set( LARGEFILES_DEFINITIONS "-D_LARGE_FILES" )
set( HAVE_LARGEFILES 1 )
endif( )
endif( )
# check with definition _LARGEFILE_SOURCE
if( NOT HAVE_LARGEFILES )
unset( HAVE_SIZEOF_OFF_T CACHE )
tde_save_and_set( CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_LARGEFILE_SOURCE" )
check_type_size( off_t SIZEOF_OFF_T )
tde_restore( CMAKE_REQUIRED_DEFINITIONS )
if( SIZEOF_OFF_T GREATER 7 )
set( LARGEFILES_DEFINITIONS "-D_LARGEFILE_SOURCE" )
set( HAVE_LARGEFILES 1 )
endif( )
endif( )
# check for fseeko/ftello
if( HAVE_LARGEFILES )
tde_save_and_set( CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} ${LARGEFILES_DEFINITIONS}" )
check_symbol_exists( "fseeko" "stdio.h" HAVE_FSEEKO )
tde_restore( CMAKE_REQUIRED_DEFINITIONS )
if( NOT HAVE_FSEEKO )
tde_save_and_set( CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} ${LARGEFILES_DEFINITIONS} -D_LARGEFILE_SOURCE" )
check_symbol_exists( "fseeko" "stdio.h" HAVE_FSEEKO )
tde_restore( CMAKE_REQUIRED_DEFINITIONS )
if( HAVE_FSEEKO )
set( LARGEFILES_DEFINITIONS "${LARGEFILES_DEFINITIONS} -D_LARGEFILE_SOURCE" )
else( )
unset( HAVE_LARGEFILES )
endif( )
endif( )
endif( )
# check results
if( HAVE_LARGEFILES )
if( "${LARGEFILES_DEFINITIONS}" STREQUAL "" )
message( STATUS "Check support for large files - Success" )
else( )
add_definitions( ${LARGEFILES_DEFINITIONS} )
message( STATUS "Check support for large files - Success with ${LARGEFILES_DEFINITIONS}" )
endif( )
set( HAVE_LARGEFILES 1 CACHE INTERNAL "Support for large files enabled" )
else( )
message( STATUS "Check support for large files - Failed" )
tde_message_fatal( "Cannot find a way to enable support for large files." )
endif( )
endif( )
endmacro( )
################################################
#####
##### Restore CMP0026 policy

Loading…
Cancel
Save