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:34:02 +0100
commit55da3149034ab1b0c756f2a07c7129b8b16bd9d2 (patch)
tree71f9d42e19dbd8ea3478d4a3cf446da607af351f
parent19102b826409f3c463f6150e30c1a52afbf89431 (diff)
downloadtde-cmake-55da3149034ab1b0c756f2a07c7129b8b16bd9d2.tar.gz
tde-cmake-55da3149034ab1b0c756f2a07c7129b8b16bd9d2.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> (cherry picked from commit 8d8c763683c5a975152b9259a1b7b89fddf34686)
-rw-r--r--modules/TDEMacros.cmake86
1 files changed, 86 insertions, 0 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake
index 9046f92..1754fb2 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 )