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

[Question] how to pass custom options to cmake via environment variable? #140

Open
leleliu008 opened this issue Jan 16, 2022 · 1 comment

Comments

@leleliu008
Copy link

leleliu008 commented Jan 16, 2022

Hello, I'm a Android developer. I'm porting large amounts of Rust projects to Android platform. I find some project use this crate to cross-compile for Android. sometime I need to pass some custom options to cmake(for example: ANDROID_ABI , ANDROID_PLATFORM , etc). I can't find environment variable like TARGET_CMAKE_FLAGS. I wanna know how to pass custom options to cmake via environment variable? Thanks.

@leleliu008
Copy link
Author

leleliu008 commented Jan 16, 2022

I find following code works for me:

export TARGET_CMAKE_TOOLCHAIN_FILE="$PWD/android.toolchain.cmake"

ANDROID_ABI=x86
ANDROID_PLATFORM=21
ANDROID_NDK_HOME=/some/path

printf '%s\n' "
        set(ANDROID_ABI "${ANDROID_ABI}")
        set(ANDROID_PLATFORM "android-${ANDROID_PLATFORM}")
        include(${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake)
        " > "$TARGET_CMAKE_TOOLCHAIN_FILE"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant