From a318f0eb492a261a60c1549e6363e9278874bf62 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Thu, 17 Apr 2025 08:58:02 +0200 Subject: [PATCH] Fix android >=24 build with NDK toolchain --- CMakeLists.txt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9396130dcc..0b09f40509 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,14 +122,17 @@ else() endif() -if(ANDROID AND CMAKE_SYSTEM_VERSION VERSION_LESS 24 AND (CMAKE_SYSTEM_PROCESSOR MATCHES "i686" OR CMAKE_SYSTEM_PROCESSOR MATCHES "armv7-a")) +if(ANDROID AND CMAKE_SYSTEM_PROCESSOR MATCHES "armv7-a|i686") # fseeko/ftello may link, but it's not usable before Android API 24 on 32-bit Android # https://android.googlesource.com/platform/bionic/+/main/docs/32-bit-abi.md - message(STATUS "Disabling fseeko/ftello for 32-bit Android before API 24") - set(HAVE_FSEEKO 0 CACHE INTERNAL "") -else() - check_function_exists(fseeko HAVE_FSEEKO) + # The API level can be in different variables, subject to actual toolchain. + string(REPLACE "android-" "" api_level "${ANDROID_PLATFORM}") + if(NOT (CMAKE_SYSTEM_VERSION GREATER_EQUAL "24" OR api_level GREATER_EQUAL "24")) + message(STATUS "Disabling fseeko/ftello for 32-bit Android before API 24") + set(HAVE_FSEEKO 0 CACHE INTERNAL "") + endif() endif() +check_function_exists(fseeko HAVE_FSEEKO) check_c_source_compiles("int main() { return __builtin_bswap16 (0) ; }" HAVE_BSWAP16) check_c_source_compiles("int main() { return __builtin_bswap32 (0) ; }" HAVE_BSWAP32)