[cmake-developers] A goal for a simple Android toolchain file.

Stephen Kelly steveire at gmail.com
Wed Mar 26 08:55:32 EDT 2014


Eric Wing wrote:
> I have been using my fork of the Android-CMake (originally from
> OpenCV) that you want to obsolete. My fork contains a lot of fixes to
> deal with more recent NDK updates and more complicated requirements
> that I have.
> https://bitbucket.org/ewing/android-cmake

It's great to have someone here who is both familiar with cmake and with 
Android!

> 
> It is completely reliant on the Android "standalone toolchain"
> technique which I vastly dislike, 

Sorry, I don't know what you're referring to. What is a standalone 
toolchain? This:
 
 https://www.assembla.com/code/android-gb-for-sharp-is01/git/nodes/debug/ndk/docs/STANDALONE-TOOLCHAIN.html

?

It looks like the primary usefulness of that is to avoid the caller having 
to specify the -sysroot. Do I misunderstand? With CMAKE_SYSROOT in CMake 
3.0, and with the platform file I proposed, I don't see what makes that 
"standalone toolchain" stuff useful. 

Can you explain?

> So while I'm not opposed to a brand new Android toolchain file, I want
> to assert that it needs to be correct and it does need to handle a
> variety of cases. So learn as much as you can from the existing ones.

My aim is to put the things which should be in a Android.cmake platform file 
shipped with CMake into such a file. Some things belong in such a file, I 
think, and others belong in a toolchain file maintained externally.

> In my fork, I spent a lot of time re-reverse-engineering the
> standard/default Android flags passed to the compiler. OpenCV took too
> many liberties with changing what Android passes normally which
> resulted in unexpected/broken behavior for some of my other projects.
> I think a very conservative, deferential approach should be taken.

If you can provide details, I think that would be useful.

> I
> would also like it to understand multiple architectures which would
> also go a long way to simplifying the end-user experience, though I'm
> worried this might take deeper CMake changes.

I expect so, but knowing what the needs are helps inform what those changes 
might look like.

 http://public.kitware.com/Bug/view.php?id=14539
 
> 
>>  set(ANDROID_SDK_ROOT "/home/stephen/android/android-sdk-linux/")
>>  set(ANDROID_NDK_ROOT "/home/stephen/android/android-ndk-r9/")
> 
> It should also handle the semi-blessed/official Android environmental
> variables like ANDROID_SDK_ROOT and ANDROID_NDK_ROOT so you don't have
> to explicitly set them in CMake scripts.

It does. Did you look at the Android.cmake I posted?

> 
>>  set(ANDROID_NDK_PLATFORM "android-18")
> 
> It should automatically detect and use the latest Android target API
> if it is not explicitly specified.

My Android.cmake also reads that from the environment. If there's a way to 
detect it automatically, that might be a good idea. Can you say how?

Can you tell me for certain whether you looked at the Android.cmake file I 
linked to already? Knowing whether you did would help our discussion I 
think.

Thanks,

Steve.





More information about the cmake-developers mailing list