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