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