Skip to content

Commit 6fd9eff

Browse files
authored
Merge pull request #494 from dyrpsf/fix-android-cross-compile
Fix: Resolve Android cross-compilation failure (Issue #458)
2 parents d44676e + 4e9d379 commit 6fd9eff

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
cmake_minimum_required(VERSION 3.15...3.26)
22

3+
# --- BEGIN ANDROID CROSS-COMPILATION FIX ---
4+
# Buildozer/python-for-android uses standard pip install which doesn't natively
5+
# pass a CMake toolchain file to scikit-build-core. This detects the Android compiler
6+
# from the environment and forces CMake into cross-compilation mode to prevent
7+
# it from building host (x86_64) binaries.
8+
if("$ENV{CC}" MATCHES "android" AND NOT DEFINED CMAKE_SYSTEM_NAME)
9+
message(STATUS "Detected Android cross-compilation via environment variables. Setting CMAKE_SYSTEM_NAME=Android")
10+
set(CMAKE_SYSTEM_NAME Android)
11+
endif()
12+
# --- END ANDROID CROSS-COMPILATION FIX ---
13+
314
project(${SKBUILD_PROJECT_NAME} LANGUAGES C)
415
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
516

0 commit comments

Comments
 (0)