summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 )