Skip to content
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

cmake toolchain doesn't work with cmake 3.7+ #254

Closed
hszhsh opened this issue Dec 2, 2016 · 15 comments
Closed

cmake toolchain doesn't work with cmake 3.7+ #254

hszhsh opened this issue Dec 2, 2016 · 15 comments
Assignees
Labels

Comments

@hszhsh
Copy link

hszhsh commented Dec 2, 2016

I'm using cmake with ndkr13b, and have a problem of selecting clang toolchain.
If I provide -DANDROID_TOOLCHAIN=gcc, cmake works fine. But with the default clang toolchain, cmake still shows the message "-- Android: Selected GCC toolchain 'arm-linux-androideabi-4.9'", and won't pass the compiler check.
Here's my cmake command. Did I miss something?

cmake -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a  -DANDROID_TOOLCHAIN=clang ${PROJECT_PATH}
@DanAlbert
Copy link
Member

I'll take a closer look tomorrow, but just FYI you shouldn't need to pass -DANDROID_TOOLCHAIN at all. Clang is the default. Could be that we don't handle the explicit argument correctly.

@hszhsh
Copy link
Author

hszhsh commented Dec 2, 2016

I tried command without -DANDROID_TOOLCHAIN, and got the some result.
My cmake version is 3.7.1.

@DanAlbert
Copy link
Member

I assumed as much, but was worth a shot.

@DanAlbert DanAlbert self-assigned this Dec 2, 2016
@hszhsh
Copy link
Author

hszhsh commented Dec 2, 2016

I have changed the cmake version to 3.6.3, and It works.

@hszhsh hszhsh closed this as completed Dec 2, 2016
@xyzz
Copy link

xyzz commented Dec 2, 2016

I had the same issue and solved it in the same way (downgrade to 3.6.3), can you perhaps document that cmake 3.7.1 does not work? Although at this point it reminds me of a certain other build system...

@DanAlbert DanAlbert added the docs label Dec 2, 2016
@DanAlbert
Copy link
Member

We should at least document this. I don't know if the Studio team is planning on updating CMake or not.

@DanAlbert DanAlbert reopened this Dec 2, 2016
@osfans
Copy link

osfans commented Dec 22, 2016

I have the same question when cmake is 3.7.1

@DanAlbert
Copy link
Member

This is something we're scheduled to talk about in the next Android C++ meeting, but December is a pretty difficult month to actually make meetings happen in :) I'll hopefully have some answers in a couple weeks.

@DanAlbert
Copy link
Member

FYI, I think for the short term anyway that answer is going to continue being "you need to use the cmake that comes with the SDK", but we should at least get some docs in place to make that clear.

osfans added a commit to osfans/trime that referenced this issue Jan 3, 2017
…chain

android/ndk#254

opencc crashes when using gcc
build breaks when using clang under cmake-3.7.1

So we should use clang under cmake-3.6 now.
@DanAlbert
Copy link
Member

Okay, the Studio folks are going to look in to getting support for vanilla (not the Studio fork) cmake. There are some changes that need to get upstreamed and possibly some more work that needs to be done for the new version, so we don't know when this is going to be available, but it is something we're investigating.

@DanAlbert
Copy link
Member

Okay, we have a tracking bug on the Studio side now: http://b.android.com/231562

Closing this one since afaik there's nothing to actually be done for the NDK on this.

@DanAlbert DanAlbert added studio and removed docs labels Jan 5, 2017
@xyzz
Copy link

xyzz commented Jan 5, 2017

Why is it a studio-only issue? There's a cmake toolchain file: ${ANDROID_NDK}/build/cmake/android.toolchain.cmake provided with the NDK. You don't need studio installed to attempt to use it.

@DanAlbert
Copy link
Member

Ah, I thought it was only a problem when used via Studio. I guess I have some work to do then.

@DanAlbert DanAlbert reopened this Jan 5, 2017
@DanAlbert DanAlbert added cmake and removed studio labels Jan 5, 2017
@osfans
Copy link

osfans commented Jan 6, 2017

https://cmake.org/cmake/help/v3.7/manual/cmake-toolchains.7.html#cross-compiling-for-android

CMake now supports Cross Compiling for Android with simple toolchain files.
It works for me.

@DanAlbert DanAlbert changed the title cmake toolchain issue cmake toolchain doesn't work with cmake 3.7+ Mar 30, 2017
@DanAlbert
Copy link
Member

Merged into r15. Will be in beta 2.

a252539783 pushed a commit to a252539783/aosp-platform-ndk that referenced this issue May 3, 2017
Test: ./validate.py # With cmake 3.7 in path
Bug: android/ndk#254
Change-Id: Ic9aaf181a508fea7d2b454d902d36e6498a3500b
(cherry picked from commit e14807b)
a252539783 pushed a commit to a252539783/aosp-platform-ndk that referenced this issue May 3, 2017
Test: ./validate.py # With cmake 3.7 in path
Bug: android/ndk#254
Change-Id: Ic9aaf181a508fea7d2b454d902d36e6498a3500b
Dschoordsch pushed a commit to heremaps/gluecodium that referenced this issue Nov 15, 2018
The CMake toolchain shipped with the NDK doesn't work with CMake-3.7.2
or 3.9.1. To ensure compatibility, use the shipped cmake binary. See
android/ndk#254 or
https://gitlab.kitware.com/cmake/cmake/issues/16708 as well as
android/ndk#504

Change-Id: I31366cd813edc44d0e62021872c63d9fc06ffb7c
FrancescoCiulla pushed a commit to FrancescoCiulla/trime that referenced this issue Jul 16, 2022
…chain

android/ndk#254

opencc crashes when using gcc
build breaks when using clang under cmake-3.7.1

So we should use clang under cmake-3.6 now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants