1 1.1 christos # - Check if _FILE_OFFSET_BITS macro needed for large files 2 1.1 christos # CHECK_FILE_OFFSET_BITS () 3 1.1 christos # 4 1.1 christos # The following variables may be set before calling this macro to 5 1.1 christos # modify the way the check is run: 6 1.1 christos # 7 1.1 christos # CMAKE_REQUIRED_FLAGS = string of compile command line flags 8 1.1 christos # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) 9 1.1 christos # CMAKE_REQUIRED_INCLUDES = list of include directories 10 1.1 christos # Copyright (c) 2009, Michihiro NAKAJIMA 11 1.1 christos # 12 1.1 christos # Redistribution and use is allowed according to the terms of the BSD license. 13 1.1 christos # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 14 1.1 christos 15 1.1 christos #INCLUDE(CheckCSourceCompiles) 16 1.1 christos 17 1.1 christos GET_FILENAME_COMPONENT(_selfdir_CheckFileOffsetBits 18 1.1 christos "${CMAKE_CURRENT_LIST_FILE}" PATH) 19 1.1 christos 20 1.1 christos MACRO (CHECK_FILE_OFFSET_BITS) 21 1.1 christos IF(NOT DEFINED _FILE_OFFSET_BITS) 22 1.1 christos MESSAGE(STATUS "Cheking _FILE_OFFSET_BITS for large files") 23 1.1 christos TRY_COMPILE(__WITHOUT_FILE_OFFSET_BITS_64 24 1.1 christos ${CMAKE_CURRENT_BINARY_DIR} 25 1.1 christos ${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c 26 1.1 christos COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}) 27 1.1 christos IF(NOT __WITHOUT_FILE_OFFSET_BITS_64) 28 1.1 christos TRY_COMPILE(__WITH_FILE_OFFSET_BITS_64 29 1.1 christos ${CMAKE_CURRENT_BINARY_DIR} 30 1.1 christos ${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c 31 1.1 christos COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_FILE_OFFSET_BITS=64) 32 1.1 christos ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64) 33 1.1 christos 34 1.1 christos IF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64) 35 1.1 christos SET(_FILE_OFFSET_BITS 64 CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files") 36 1.1 christos MESSAGE(STATUS "Cheking _FILE_OFFSET_BITS for large files - needed") 37 1.1 christos ELSE(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64) 38 1.1 christos SET(_FILE_OFFSET_BITS "" CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files") 39 1.1 christos MESSAGE(STATUS "Cheking _FILE_OFFSET_BITS for large files - not needed") 40 1.1 christos ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64) 41 1.1 christos ENDIF(NOT DEFINED _FILE_OFFSET_BITS) 42 1.1 christos 43 1.1 christos ENDMACRO (CHECK_FILE_OFFSET_BITS) 44