Get CMake to support Android and iOS platforms - #312
LeventSevgili wants to merge 1 commit into
Conversation
Also edit some files to success the build.
|
When this will be merged? |
|
Just a note for the iOS package distribution, I see in the README, a dynamic library (.dylib) this has not been allowed for a long time on Apple stores, it is mandatory to have a static library: .a or .xcframework! I will soon post a github URL of one of my repositories, for :
Which will contain all the pre-compiled libraries in static form that you can retrieve via the artifacts of the Github Actions CI: protobuf + OpenSSL + GameNetworkingSockets, with obviously the latest version latest release of the libraries! I automated it from a CI so I would just have to change the tag / commitsha of protobuf (+absail) / openssl / GameNetworkingSockets, when I have the devkit for consoles I will also make the request to extend on consoles! |
|
If someone need build for Android with a newer NDK. this worked for me using NDK 26.1.10909125 |
Taken from PR #312. The NDK toolchain sets CMAKE_SYSTEM_NAME to Android, which previously hit the "Could not identify your target operating system" error in both CMakeLists files. Plat_IsInDebugSession now has an Android case. This does not make Android build on its own. Still needed: link liblog, and cast bionic's INADDR_LOOPBACK and INADDR_BROADCAST (unsigned long on LP64) to uint32 in netadr.cpp.
On Android, bionic takes these straight from the kernel headers, where they are unsigned long. On LP64 that is 64 bits, which trips the compile-time size assert in BigDWord. glibc redefines them as in_addr_t, so Linux never saw it. No change on any other platform. Noted in PR #312.
Static protobuf references __android_log_write, so the client library must link liblog on Android. Noted in PR #312.
|
Hi @LeventSevgili, First, an apology: this PR has been open since early 2024 and it's nearly I've now taken the parts of this I could, and I want to explain what I did Merged, with you as author (baca770): the Android branches in both Merged as follow-up commits, credited to this PR (2e5eb56, 7386ffc): linking Not taken: the iOS side has since been covered by a separate effort (#428) With the merged pieces, master should now configure and compile for Android Thanks again for taking the time to put this together and share it, and |
Taken from PR #312. The NDK toolchain sets CMAKE_SYSTEM_NAME to Android, which previously hit the "Could not identify your target operating system" error in both CMakeLists files. Plat_IsInDebugSession now has an Android case. This does not make Android build on its own. Still needed: link liblog, and cast bionic's INADDR_LOOPBACK and INADDR_BROADCAST (unsigned long on LP64) to uint32 in netadr.cpp. (cherry picked from commit baca770)
On Android, bionic takes these straight from the kernel headers, where they are unsigned long. On LP64 that is 64 bits, which trips the compile-time size assert in BigDWord. glibc redefines them as in_addr_t, so Linux never saw it. No change on any other platform. Noted in PR #312. (cherry picked from commit 2e5eb56)
I always wanted to get CMake to support Android and iOS platforms. I had a little time window and managed to work it and I am happy to share. I will be super glad if it helps to someone!
It may have points to discuss. I'm glad to iterate. I had comments on files. Thanks!