CMAKE_SYSTEM_NAME defaults to Android in Termux: A semantic conflict for native builds

Hi CMake developers,

I am doing a native local build inside Termux.

To be precise, Termux is not a traditional Android app development environment. It is essentially a standard Linux environment, with the only difference being that it uses Android’s Bionic libc instead of Glibc. There is no Android cross-compilation (like building an APK or using the NDK) involved.

The Conceptual/Semantic Error:

In CMake’s design model, the label Android for CMAKE_SYSTEM_NAME historically implies cross-compilation (i.e., building an Android target from a different host). However, in Termux, this is a native build.

When CMake automatically sets CMAKE_SYSTEM_NAME to Android, downstream projects (like OpenCV) incorrectly assume the Android cross-compilation context and try to look for the Android SDK. This causes the build to fail because no SDK exists (and is not needed) in a native Bionic environment.

Currently, I bypass this by manually passing -DCMAKE_SYSTEM_NAME=Linux, which forces the native Linux path and works.

Is this considered expected behavior for native Bionic builds? Or is there an officially recommended approach to handle this semantic conflict?

Note: I used AI to help translate and structure this post. The technical issue described, the conceptual analysis, and the temporary workaround (-DCMAKE_SYSTEM_NAME=Linux) are entirely based on my actual experience and testing in Termux.