File: TestLargeFiles.cmake

package info (click to toggle)
libsndfile 1.2.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,108 kB
  • sloc: ansic: 55,350; cpp: 1,108; python: 791; makefile: 545; sh: 539; cs: 122
file content (121 lines) | stat: -rw-r--r-- 4,375 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
include (CheckIncludeFile)
include (CheckTypeSize)
include (CMakePushCheckState)

macro (TEST_LARGE_FILES VARIABLE)

if (NOT DEFINED ${VARIABLE})

	cmake_push_check_state()

	message (STATUS "")
	message (STATUS "")
	message (STATUS "Checking large files support...")

	if (WIN32)
		set (${VARIABLE} 1 CACHE INTERNAL "Result of tests for large file support" FORCE)
		message (STATUS "")
		message (STATUS "Result of checking large files support: supported with WinAPI")
	else ()

		message (STATUS "")
		check_include_file(sys/types.h HAVE_SYS_TYPES_H)
		check_include_file(stdint.h HAVE_STDINT_H)
		check_include_file(stddef.h HAVE_STDDEF_H)
		message (STATUS "")

		message (STATUS "Checking size of off_t without any definitions:")
		check_type_size (off_t SIZEOF_OFF_T)
		message (STATUS "Checking of off_t without any definitions: ${SIZEOF_OFF_T}")
		if (SIZEOF_OFF_T EQUAL 8)
			set (LARGE_FILES_DEFINITIONS "" CACHE INTERNAL "64-bit off_t required definitions")
			set (FILE64 TRUE)
		else ()
			unset (HAVE_SIZEOF_OFF_T CACHE)
			unset (SIZEOF_OFF_T CACHE)
			unset (SIZEOF_OFF_T_CODE CACHE)
			cmake_pop_check_state()
			set (FILE64 FALSE)
		endif ()

		if (NOT FILE64)
			set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} /D_FILE_OFFSET_BITS=64)
			message (STATUS "")
			message (STATUS "Checking size of off_t with _FILE_OFFSET_BITS=64:")
			check_type_size (off_t SIZEOF_OFF_T)
			message (STATUS "Checking size of off_t with _FILE_OFFSET_BITS=64: ${SIZEOF_OFF_T}")
			if (SIZEOF_OFF_T EQUAL 8)
				set (_FILE_OFFSET_BITS 64 CACHE INTERNAL "")
				set (_FILE_OFFSET_BITS_CODE "#define _FILE_OFFSET_BITS 64" CACHE INTERNAL "")
				set (LARGE_FILES_DEFINITIONS ${LARGE_FILES_DEFINITIONS} "/D_FILE_OFFSET_BITS=64" CACHE INTERNAL "64-bit off_t required definitions")
				set (FILE64 TRUE)
			else ()
				set (_FILE_OFFSET_BITS_CODE "" CACHE INTERNAL "")
				unset (HAVE_SIZEOF_OFF_T CACHE)
				unset (SIZEOF_OFF_T CACHE)
				unset (SIZEOF_OFF_T_CODE CACHE)
				cmake_pop_check_state()
				set (FILE64 FALSE)
			endif ()
		endif ()

		if (NOT FILE64)
			set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} /D_LARGE_FILES)
			message (STATUS "")
			message (STATUS "Checking size of off_t with _LARGE_FILES:")
			check_type_size (off_t SIZEOF_OFF_T)
			message (STATUS "Checking size of off_t with _LARGE_FILES: ${SIZEOF_OFF_T}")
			if (SIZEOF_OFF_T EQUAL 8)
				set (_LARGE_FILES 1 CACHE INTERNAL "")
				set (LARGE_FILES_DEFINITIONS ${LARGE_FILES_DEFINITIONS} "/D_LARGE_FILES" CACHE INTERNAL "64-bit off_t required definitions")
				set (FILE64 TRUE)
			else ()
				unset (HAVE_SIZEOF_OFF_T CACHE)
				unset (SIZEOF_OFF_T CACHE)
				unset (SIZEOF_OFF_T_CODE CACHE)
				cmake_pop_check_state()
				set (FILE64 FALSE)
			endif ()
		endif ()

		if (NOT FILE64)
			set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} /D_LARGEFILE_SOURCE)
			unset (HAVE_SIZEOF_OFF_T CACHE)
			unset (SIZEOF_OFF_T CACHE)
			unset (SIZEOF_OFF_T_CODE CACHE)
			message (STATUS "")
			message (STATUS "Checking size of off_t with _LARGEFILE_SOURCE:")
			check_type_size (off_t SIZEOF_OFF_T)
			message (STATUS "Checking size of off_t with _LARGEFILE_SOURCE: ${SIZEOF_OFF_T}")
			if (SIZEOF_OFF_T EQUAL 8)
				set (_LARGEFILE_SOURCE 1 CACHE INTERNAL "")
				set (LARGE_FILES_DEFINITIONS ${LARGE_FILES_DEFINITIONS} "/D_LARGEFILE_SOURCE"  CACHE INTERNAL "64-bit off_t required definitions")
				set (FILE64 TRUE)
			else ()
				cmake_pop_check_state()
				set (FILE64 FALSE)
			endif ()
		endif ()

		message (STATUS "")
		if (FILE64)
			set (${VARIABLE} 1 CACHE INTERNAL "Result of tests for large file support" FORCE)
			if (NOT SIZEOF_OFF_T_REQURED_DEFINITIONS)
				message (STATUS "Result of checking large files support: supported")
			else ()
				message (STATUS "Result of checking large files support: supported with ${LARGE_FILES_DEFINITIONS}")
				message (STATUS "Add LARGE_FILES_DEFINITIONS to your compiler definitions or configure with _FILE_OFFSET_BITS,")
				message (STATUS "_FILE_OFFSET_BITS_CODE, _LARGE_FILES and _LARGEFILE_SOURCE variables.")
			endif ()
		else ()
			message ("Result of checking large files support: not supported")
			set (${VARIABLE} 0 CACHE INTERNAL "Result of test for large file support" FORCE)
		endif ()
		message ("")
		message ("")

	endif ()

endif (NOT DEFINED ${VARIABLE})

endmacro (TEST_LARGE_FILES VARIABLE)