Fixed android toolchain with newest NDK#21465
Conversation
ANDROID_NATIVE_API_LEVEL has been removed from NDK cmake toolchain so we now have to use ANDROID_PLATFORM
|
why not setting both, to preserve compatibility with older ndk? |
|
I noticed some weird stuff when setting both. Some versions of the NDK do not execute the same code when both are set (checks are made in the toolchain if both variables are set or not set). |
|
cc @talregev @tronical @jherico @huangqinjin @jamiebk for review this PR. |
|
CC @holmescn @m-kuhn |
|
If I recall correctly, since NDK 19, Seems the latest NDK dropped |
File an NDK bug please. |
|
Building with this change failed on compiler-detect at least on armv6: So in order to fix the usage of the newest NDK, a little bit more work is required here. |
|
Filed bug android/ndk#1610. |
|
I think |
The issue with setting both is that the 2 variables are not fully compatible (in syntax), depending on the NDK version used by the caller. Not sure what is the best solution is, just that for people updating to the latest NDK, vcpkg is not working anymore. |
|
If both not working, then we need to separate the update according to NDK version. |
I unfortunately won't have the time to test this at the moment. Maybe someone has a better idea, but currently vcpkg is broken if you get latest NDK. Setting both variables will break vcpkg for people with an older NDK depending on what is set in their |
|
You don't have to include the cmake to find version number. maybe simple parse from one of the txt/cmake file for ndk version. |
|
I look on the |
|
@talregev, not sure I got your idea. |
|
@AenBleidd I am writing you in discord. |
|
ok. I understand the confusion. if(CMAKE_SYSTEM_VERSION MATCHES "[0-9]+$")
set(ANDROID_PLATFORM android-${CMAKE_SYSTEM_VERSION} CACHE STRING "")
else()
set(ANDROID_PLATFORM ${CMAKE_SYSTEM_VERSION} CACHE STRING "")
endif() |
|
We change our triplets to |
|
So everyone approved this changes? |
|
I think before we can refactor the entire build process, any patches would temporarily work. Although Android NDK is not evolved so fast, version fragmentation is serious. Issue #21345 tried to discuss and resolve this problem from scratch. But any effort is welcome. |
|
@JackBoosY, I'm ok with these changes. |
|
@JackBoosY Please consider my suggestion before merge. |
@christophe-calmejane Can you try my suggestion? |
|
I quickly checked and it fails if you set CMAKE_SYSTEM_VERSION to android-15 for exemple |
|
There is no android-15. the number is no ndk. we using |
|
https://developer.android.com/ndk/downloads/revision_history from ndk 18 google drop the support for android 15
|
|
Sorry I just used any random number when replying, use any number you want, it fails with your change if you set android-NN |
Can you tell me the ndk version are you using, and past here the error? |
|
Since I have less knowledge with Android, I will follow the opinions of most people. |
Your code causes |
|
Thank you that you find error in my regular expression. I meant if the var contain only digits. can you fix it? |
I understand the my error Can you test it with the fix? if(CMAKE_SYSTEM_VERSION MATCHES "^[0-9]+$")
set(ANDROID_PLATFORM android-${CMAKE_SYSTEM_VERSION} CACHE STRING "")
else()
set(ANDROID_PLATFORM ${CMAKE_SYSTEM_VERSION} CACHE STRING "")
endif() |
|
Sorry for the long delay, I'm gonna test some changes as soon as I find a bit of time, hopefully before the end of the week. |
|
I pushed a new commit, including your proposal. Seems fine on my side. |
|
@talregev What's your opinion now? |
|
I am happy with the changes. It also support back compatibility. |
|
Maybe we should also update our docs. |
I don't see anywhere any of these variables are mentioned in our docs for Android. |
|
Thanks for the bugfix! |
Describe the pull request
ANDROID_NATIVE_API_LEVEL has been removed from NDK cmake toolchain so we now have to use ANDROID_PLATFORM
What does your PR fix?
Using latest android NDK
Which triplets are supported/not supported? Have you updated the CI baseline?
Only affects android triplets
Does your PR follow the maintainer guide?
Yes