summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2019-01-17 00:40:08 +0100
committerSlávek Banko <slavek.banko@axis.cz>2019-01-28 16:30:27 +0100
commit8d8c763683c5a975152b9259a1b7b89fddf34686 (patch)
tree44edd1e5022dd20f05f76033eef740a8631345c6
parent4512d95ca64fd0334fa1c28a7630012d87dc99a3 (diff)
downloadtde-cmake-8d8c7636.tar.gz
tde-cmake-8d8c7636.zip
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>
-rw-r--r--modules/TDEMacros.cmake86
1 files changed, 86 insertions, 0 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake
index 15008b8..8f86c62 100644
--- a/modules/TDEMacros.cmake
+++ b/modules/TDEMacros.cmake
@@ -1929,6 +1929,92 @@ 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
if( POLICY CMP0026 )