1 # - Check if the _FILE_OFFSET_BITS macro is needed for large files
2 # CHECK_FILE_OFFSET_BITS()
4 # The following variables may be set before calling this macro to
5 # modify the way the check is run:
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, Chris Robinson
12 # Redistribution and use is allowed according to the terms of the LGPL license.
15 MACRO(CHECK_FILE_OFFSET_BITS)
17 IF(NOT DEFINED _FILE_OFFSET_BITS)
18 MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files")
19 TRY_COMPILE(__WITHOUT_FILE_OFFSET_BITS_64
21 ${CMAKE_SOURCE_DIR}/cmake/CheckFileOffsetBits.c
22 COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
23 IF(NOT __WITHOUT_FILE_OFFSET_BITS_64)
24 TRY_COMPILE(__WITH_FILE_OFFSET_BITS_64
26 ${CMAKE_SOURCE_DIR}/cmake/CheckFileOffsetBits.c
27 COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_FILE_OFFSET_BITS=64)
28 ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64)
30 IF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64)
31 SET(_FILE_OFFSET_BITS 64 CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files")
32 MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files - 64")
33 ELSE(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64)
34 SET(_FILE_OFFSET_BITS "" CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files")
35 MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files - not needed")
36 ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64)
37 ENDIF(NOT DEFINED _FILE_OFFSET_BITS)
39 ENDMACRO(CHECK_FILE_OFFSET_BITS)