1 # CMake support for fseeko
3 # Based on FindLFS.cmake by
4 # Copyright (C) 2016 Julian Andres Klode <jak@debian.org>.
6 # Permission is hereby granted, free of charge, to any person
7 # obtaining a copy of this software and associated documentation files
8 # (the "Software"), to deal in the Software without restriction,
9 # including without limitation the rights to use, copy, modify, merge,
10 # publish, distribute, sublicense, and/or sell copies of the Software,
11 # and to permit persons to whom the Software is furnished to do so,
12 # subject to the following conditions:
14 # The above copyright notice and this permission notice shall be
15 # included in all copies or substantial portions of the Software.
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 # This defines the following variables
28 # FSEEKO_DEFINITIONS - List of definitions to pass to add_definitions()
29 # FSEEKO_COMPILE_OPTIONS - List of definitions to pass to add_compile_options()
30 # FSEEKO_LIBRARIES - List of libraries and linker flags
31 # FSEEKO_FOUND - If there is Large files support
34 include(CheckCSourceCompiles)
35 include(FindPackageHandleStandardArgs)
36 include(CMakePushCheckState)
38 # Check for the availability of fseeko()
39 # The cases handled are:
42 # * Preprocessor flag -D_LARGEFILE_SOURCE
44 function(_fseeko_check)
46 cmake_push_check_state()
47 set(CMAKE_REQUIRED_QUIET 1)
48 set(CMAKE_REQUIRED_DEFINITIONS ${LFS_DEFINITIONS})
49 message(STATUS "Looking for native fseeko support")
50 check_symbol_exists(fseeko stdio.h fseeko_native)
51 cmake_pop_check_state()
53 message(STATUS "Looking for native fseeko support - found")
54 set(FSEEKO_FOUND TRUE)
56 message(STATUS "Looking for native fseeko support - not found")
60 # See if it's available with _LARGEFILE_SOURCE.
61 cmake_push_check_state()
62 set(CMAKE_REQUIRED_QUIET 1)
63 set(CMAKE_REQUIRED_DEFINITIONS ${LFS_DEFINITIONS} "-D_LARGEFILE_SOURCE")
64 check_symbol_exists(fseeko stdio.h fseeko_need_largefile_source)
65 cmake_pop_check_state()
66 if (fseeko_need_largefile_source)
67 message(STATUS "Looking for fseeko support with _LARGEFILE_SOURCE - found")
68 set(FSEEKO_FOUND TRUE)
69 set(_fseeko_cppflags "-D_LARGEFILE_SOURCE")
71 message(STATUS "Looking for fseeko support with _LARGEFILE_SOURCE - not found")
75 set(FSEEKO_DEFINITIONS ${_fseeko_cppflags} CACHE STRING "Extra definitions for fseeko support")
76 set(FSEEKO_COMPILE_OPTIONS "" CACHE STRING "Extra compiler options for fseeko support")
77 set(FSEEKO_LIBRARIES "" CACHE STRING "Extra definitions for fseeko support")
78 set(FSEEKO_FOUND ${FSEEKO_FOUND} CACHE INTERNAL "Found fseeko")
85 find_package_handle_standard_args(FSEEKO "Could not find fseeko. Set FSEEKO_DEFINITIONS, FSEEKO_COMPILE_OPTIONS, FSEEKO_LIBRARIES." FSEEKO_FOUND)