Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Add android toolchains #10

Closed
headupinclouds opened this issue May 4, 2015 · 19 comments
Closed

Add android toolchains #10

headupinclouds opened this issue May 4, 2015 · 19 comments
Milestone

Comments

@headupinclouds
Copy link
Contributor

https://code.google.com/p/android-cmake/

@headupinclouds
Copy link
Contributor Author

Initial android-cmake toolchain pushed to polly/android branch as-is to get things going.

@ruslo
Copy link
Owner

ruslo commented May 4, 2015

Thanks, merged e670b4c

@ruslo ruslo added this to the 0.7 milestone May 4, 2015
@ruslo
Copy link
Owner

ruslo commented May 4, 2015

@headupinclouds
Copy link
Contributor Author

After looking at the diff, that seems to be a better starting point. I'll
move the other one aside to serve as a reference and add the latest android
toolchain from OpenCV. It appears to be identical but with a few small
updates.

#    LIBRARY_OUTPUT_PATH_ROOT should be set in cache to determine where
Android
#    libraries will be installed.
#    Default is ${CMAKE_SOURCE_DIR}, and the android libs will always be
#    under the ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}
#    (depending on the target ABI). This is convenient for Android
packaging.

On Mon, May 4, 2015 at 12:42 PM, Ruslan Baratov notifications@github.com
wrote:

OpenCV Android toolchain:
https://github.com/Itseez/opencv/blob/master/platforms/android/android.toolchain.cmake


Reply to this email directly or view it on GitHub
#10 (comment).

@ruslo
Copy link
Owner

ruslo commented May 17, 2015

@ruslo
Copy link
Owner

ruslo commented May 18, 2015

CMake target properties:

@ruslo
Copy link
Owner

ruslo commented May 18, 2015

@ruslo
Copy link
Owner

ruslo commented May 18, 2015

one more example: https://github.com/Discordia/android-cmake-example

@pretyman
Copy link
Contributor

Merge f930e10 allows the toolchain to be used with hunter.

However there are still a few bits missing for the toolchain file in general:
Once the STL implementation is chosen, its lib directory is not added to the ANDROID_LINKER_FLAGS nor the linking flags to link to the library.

I updated on my repo a fix for this: f85df73 by creating an ANDROID_STL_LIB_DIR and adding it to the ANDROID_LINKER_FLAGS if gnustl_static is chosen, but would be nice to hear from whoever uses other options for ANDROID_STL on a better solution to deal with this.

ping @headupinclouds

EDIT: Maybe it is a bad idea to hardwire the ANDROID_STL on the ANDROID_LINKER_FLAGS (ANDROID_LINKER_FLAGS sets the value for CMAKE_EXE_LINKER_FLAGS, CMAKE_SHARED_LINKER_FLAGS and CMAKE_STATIC_LINKER_FLAGS) but ANDROID_STL_LIB_DIR should be useful to know where the directory of the lib for the chosen STL is.

@ruslo
Copy link
Owner

ruslo commented May 27, 2015

I've removed Android*.cmake from Polly (31dcb9d) since it's not toolchain related stuff.

Can be used by Hunter: https://github.com/ruslo/hunter/wiki/pkg.android.modules

@ruslo
Copy link
Owner

ruslo commented May 27, 2015

@headupinclouds f89ebf3 I think https://github.com/taka-no-me/android-cmake is the original repo so probably version from OpenCV is older. So I guess we can move android.toolchain.cmake.origin back and remove android.toolchain.cmake (?)

@headupinclouds
Copy link
Contributor Author

@ruslo Agreed. It looks like the taka-no-me repository is actively being updated ("authored 10 days ago"). I like the idea of using this one, since it will probably be easier to push and pull changes from upstream as needed.

@ruslo
Copy link
Owner

ruslo commented May 27, 2015

I've added android-ndk-r10e toolchain: https://github.com/ruslo/polly/wiki/Toolchain-list#android-ndk-xxx

Switch between different ndk versions was made similar to iOS way. You can set different ANDROID_NDK_xxx environment variables and build.py will pick the right version and add ANDROID_NDK CMake variable.

Simple examples compile fine: https://github.com/ruslo/polly/tree/master/examples

@pretyman
Copy link
Contributor

Guys, if you are going to revert to that toolchain, please be sure that it sets CMAKE_AR CMAKE_ANDROID_API

And be aware that CMAKE_FORCE_C_COMPILER( "${CMAKE_C_COMPILER}" GNU ) sets the forced compiler which makes hunter fail.

@ruslo
Copy link
Owner

ruslo commented May 27, 2015

Guys, if you are going to revert to that toolchain, please be sure that it sets CMAKE_AR CMAKE_ANDROID_API

I'm planning to cherry-pick your changes

@pretyman
Copy link
Contributor

Sorry, I didn't mean CMAKE_AR, make sure it sets CMAKE_C_PROCESSOR is what I meant - sorry, I wrote it in a hurry.

Anyway, as discussed in #16 (comment) it makes sense that these changes go to upstream and be reviewed by people who have been maintaining this file longer.

@pretyman
Copy link
Contributor

This has been taken care of with the following pull request: taka-no-me/android-cmake#53

@ruslo
Copy link
Owner

ruslo commented Jun 1, 2015

Usage example: https://github.com/forexample/android-cmake

@ruslo
Copy link
Owner

ruslo commented Jun 2, 2015

Well, looks like there is no need to create APK to run executable on device. It's possible to create simple console application and run it using adb shell. So it's easy to orginize testing with CMake's add_test:

@ruslo ruslo closed this as completed Jun 21, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants