Skip to content

Fix android compilation #829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

abique
Copy link

@abique abique commented Apr 14, 2025

See for reference microsoft/vcpkg#44940

@ktmf01
Copy link
Collaborator

ktmf01 commented Apr 14, 2025

@robUx4 Could you please take a look at this? This touches your fix from #691 I'd rather not have this break something else again, and I don't have a build system to test it with, neither does CI cover it

@robUx4
Copy link
Contributor

robUx4 commented Apr 15, 2025

This seems based on bogus assumptions: microsoft/vcpkg#44940 (comment)

The recommended NDK toolchain (aka "legacy") sets CMAKE_SYSTEM_VERSION to 1, so libflac's approach to determine ftello absence is flawed even with vcpkg passing value 28 in.

https://android.googlesource.com/platform/ndk/+/refs/heads/main/build/cmake/android-legacy.toolchain.cmake#38

This is true if ANDROID_USE_LEGACY_TOOLCHAIN_FILE is not set or explicitly set to OFF in the environment. People opting out of the legacy mode will have the proper value. On the other hand, the documentation says people shouldn't use that...

So it's true that the value is not reliable enough. ANDROID_NATIVE_API_LEVEL seems appropriate although I think ANDROID_PLATFORM is the right one to use here. 2k uses vs 1.7k. Also the NDK CMake file puts it in the read-only variables: "We'll keep these around for the existing projects that still use them.".

Note that this is only for people using the recommended cmake toolchain file provided by the NDK. In VLC for example we relied on CMake until recently and still do on VLC 3.0 (stable branch). Neither ANDROID_PLATFORM nor ANDROID_NATIVE_API_LEVEL exist there. In this case CMAKE_SYSTEM_VERSION seems the only way to tell the NDK target version.

TLDR: I think both values need to be checked. The PR in its current state will break the VLC 3.0 build.

@abique
Copy link
Author

abique commented Apr 15, 2025

I'm not expert here, I'm just forwarding what we've done in VCPKG.

@robUx4
Copy link
Contributor

robUx4 commented Apr 15, 2025

This is one of the downside of VCPKG, they make patch locally and don't send them upstream for review. It's good that you submit it here @abique. That patch might be enough for VCPKG that may force the use of the android.toolchain.cmake file.

For the more general case I think the ANDROID_PLATFORM and CMAKE_SYSTEM_VERSION need to be read first (priority to ANDROID_PLATFORM). For VLC the CMAKE_SYSTEM_VERSION set to 1 is not an issue because we don't build for anything higher than API 21 (so the check for < 24 is always true).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants