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